2021-04-23 02:34:00 +00:00
|
|
|
frappe.ui.form.ControlData = class ControlData extends frappe.ui.form.ControlData {
|
2020-12-01 07:34:53 +00:00
|
|
|
make_input() {
|
2021-04-23 02:34:00 +00:00
|
|
|
super.make_input();
|
2020-12-01 07:34:53 +00:00
|
|
|
if (this.df.options == 'Phone') {
|
|
|
|
this.setup_phone();
|
|
|
|
}
|
2021-03-09 14:58:00 +00:00
|
|
|
if (this.frm && this.frm.fields_dict) {
|
|
|
|
Object.values(this.frm.fields_dict).forEach(function(field) {
|
2021-04-23 02:34:00 +00:00
|
|
|
if (field.df.read_only === 1 && field.df.options === 'Phone'
|
2021-03-09 14:58:00 +00:00
|
|
|
&& field.disp_area.style[0] != 'display' && !field.has_icon) {
|
|
|
|
field.setup_phone();
|
|
|
|
field.has_icon = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2021-04-23 02:34:00 +00:00
|
|
|
}
|
2020-12-01 07:34:53 +00:00
|
|
|
setup_phone() {
|
|
|
|
if (frappe.phone_call.handler) {
|
2021-02-22 13:58:01 +00:00
|
|
|
let control = this.df.read_only ? '.control-value' : '.control-input';
|
|
|
|
this.$wrapper.find(control)
|
2020-12-01 07:34:53 +00:00
|
|
|
.append(`
|
|
|
|
<span class="phone-btn">
|
|
|
|
<a class="btn-open no-decoration" title="${__('Make a call')}">
|
2020-12-22 07:02:13 +00:00
|
|
|
${frappe.utils.icon('call')}
|
2020-12-01 07:34:53 +00:00
|
|
|
</span>
|
|
|
|
`)
|
|
|
|
.find('.phone-btn')
|
|
|
|
.click(() => {
|
|
|
|
frappe.phone_call.handler(this.get_value(), this.frm);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2021-04-23 02:34:00 +00:00
|
|
|
};
|