From 6b995f73251ecfdf5cdf9421aecab205782d6841 Mon Sep 17 00:00:00 2001 From: ZGaetano Date: Tue, 12 May 2026 00:12:53 -0400 Subject: [PATCH] v2.1: settings SMS fields + HD Ticket/Contact/Lead form JS: contact.js --- voxtelesys_integration/public/js/contact.js | 40 +++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 voxtelesys_integration/public/js/contact.js diff --git a/voxtelesys_integration/public/js/contact.js b/voxtelesys_integration/public/js/contact.js new file mode 100644 index 0000000..dc3f7e2 --- /dev/null +++ b/voxtelesys_integration/public/js/contact.js @@ -0,0 +1,40 @@ +/** + * Contact form JS — Voxtelesys call/SMS history sidebar. + * + * The click-to-call icon next to phone fields is already provided by Frappe + * core (Phone fieldtype) — we override frappe.phone_call.handler globally + * in voxtelesys_call_popup.js, so any phone field on any doctype routes + * through Voxtelesys automatically. + * + * This file's job is to render call/SMS history for the contact in the + * sidebar. + */ +frappe.ui.form.on("Contact", { + refresh(frm) { + if (!frappe.boot.voxtelesys || !frappe.boot.voxtelesys.enabled) return; + if (frm.is_new()) return; + + Promise.all([ + frappe.call({ + method: "voxtelesys_integration.api.voxtelesys.get_linked_call_logs", + args: { doctype: frm.doctype, name: frm.docname }, + }), + frappe.call({ + method: "voxtelesys_integration.api.sms.get_linked_sms_logs", + args: { doctype: frm.doctype, name: frm.docname }, + }), + ]).then(([calls, sms]) => { + const callCount = (calls.message || []).length; + const smsCount = (sms.message || []).length; + if (!callCount && !smsCount) return; + frm.dashboard.add_section( + `
+ ${callCount ? `${callCount} ${__("calls")}` : ""} + ${callCount && smsCount ? " · " : ""} + ${smsCount ? `${smsCount} ${__("SMS")}` : ""} +
`, + __("Voxtelesys Activity") + ); + }); + }, +});