blob: 1c3e3147976d858e723a622c6a7ed8a5420712e1 [file] [log] [blame]
Faris Ansari1fe891b2021-04-23 08:04:00 +05301frappe.ui.form.ControlData = class ControlData extends frappe.ui.form.ControlData {
Leela vadlamudia3845a92020-12-01 13:04:53 +05302 make_input() {
Faris Ansari1fe891b2021-04-23 08:04:00 +05303 super.make_input();
Leela vadlamudia3845a92020-12-01 13:04:53 +05304 if (this.df.options == 'Phone') {
5 this.setup_phone();
6 }
Shariq Ansari261c4212021-03-09 20:28:00 +05307 if (this.frm && this.frm.fields_dict) {
8 Object.values(this.frm.fields_dict).forEach(function(field) {
Faris Ansari1fe891b2021-04-23 08:04:00 +05309 if (field.df.read_only === 1 && field.df.options === 'Phone'
Shariq Ansari261c4212021-03-09 20:28:00 +053010 && field.disp_area.style[0] != 'display' && !field.has_icon) {
11 field.setup_phone();
12 field.has_icon = true;
13 }
14 });
15 }
Faris Ansari1fe891b2021-04-23 08:04:00 +053016 }
Leela vadlamudia3845a92020-12-01 13:04:53 +053017 setup_phone() {
18 if (frappe.phone_call.handler) {
Shariq Ansari8676bed2021-02-22 19:28:01 +053019 let control = this.df.read_only ? '.control-value' : '.control-input';
20 this.$wrapper.find(control)
Leela vadlamudia3845a92020-12-01 13:04:53 +053021 .append(`
22 <span class="phone-btn">
23 <a class="btn-open no-decoration" title="${__('Make a call')}">
Shivam Mishra46bc7ca2020-12-22 12:32:13 +053024 ${frappe.utils.icon('call')}
Leela vadlamudia3845a92020-12-01 13:04:53 +053025 </span>
26 `)
27 .find('.phone-btn')
28 .click(() => {
29 frappe.phone_call.handler(this.get_value(), this.frm);
30 });
31 }
32 }
Faris Ansari1fe891b2021-04-23 08:04:00 +053033};