Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 1 | frappe.ui.form.ControlData = class ControlData extends frappe.ui.form.ControlData { |
Leela vadlamudi | a3845a9 | 2020-12-01 13:04:53 +0530 | [diff] [blame] | 2 | make_input() { |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 3 | super.make_input(); |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 4 | if (this.df.options == "Phone") { |
Leela vadlamudi | a3845a9 | 2020-12-01 13:04:53 +0530 | [diff] [blame] | 5 | this.setup_phone(); |
| 6 | } |
Shariq Ansari | 261c421 | 2021-03-09 20:28:00 +0530 | [diff] [blame] | 7 | if (this.frm && this.frm.fields_dict) { |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 8 | Object.values(this.frm.fields_dict).forEach(function (field) { |
| 9 | if ( |
| 10 | field.df.read_only === 1 && |
| 11 | field.df.options === "Phone" && |
| 12 | field.disp_area.style[0] != "display" && |
| 13 | !field.has_icon |
| 14 | ) { |
Suraj Shetty | afaa85f | 2023-06-14 15:54:27 +0530 | [diff] [blame] | 15 | field.setup_phone && field.setup_phone(); |
Shariq Ansari | 261c421 | 2021-03-09 20:28:00 +0530 | [diff] [blame] | 16 | field.has_icon = true; |
| 17 | } |
| 18 | }); |
| 19 | } |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 20 | } |
Leela vadlamudi | a3845a9 | 2020-12-01 13:04:53 +0530 | [diff] [blame] | 21 | setup_phone() { |
| 22 | if (frappe.phone_call.handler) { |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 23 | let control = this.df.read_only ? ".control-value" : ".control-input"; |
| 24 | this.$wrapper |
| 25 | .find(control) |
| 26 | .append( |
| 27 | ` |
Leela vadlamudi | a3845a9 | 2020-12-01 13:04:53 +0530 | [diff] [blame] | 28 | <span class="phone-btn"> |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 29 | <a class="btn-open no-decoration" title="${__("Make a call")}"> |
| 30 | ${frappe.utils.icon("call")} |
Leela vadlamudi | a3845a9 | 2020-12-01 13:04:53 +0530 | [diff] [blame] | 31 | </span> |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 32 | ` |
| 33 | ) |
| 34 | .find(".phone-btn") |
Leela vadlamudi | a3845a9 | 2020-12-01 13:04:53 +0530 | [diff] [blame] | 35 | .click(() => { |
| 36 | frappe.phone_call.handler(this.get_value(), this.frm); |
| 37 | }); |
| 38 | } |
| 39 | } |
Faris Ansari | 1fe891b | 2021-04-23 08:04:00 +0530 | [diff] [blame] | 40 | }; |