v2.1: settings SMS fields + HD Ticket/Contact/Lead form JS: contact.js
This commit is contained in:
parent
b1a00c8bd9
commit
6b995f7325
1 changed files with 40 additions and 0 deletions
40
voxtelesys_integration/public/js/contact.js
Normal file
40
voxtelesys_integration/public/js/contact.js
Normal file
|
|
@ -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(
|
||||||
|
`<div class="vtx-contact-stats">
|
||||||
|
${callCount ? `<a href="/app/voxtelesys-call-log?links.link_name=${frm.docname}">${callCount} ${__("calls")}</a>` : ""}
|
||||||
|
${callCount && smsCount ? " · " : ""}
|
||||||
|
${smsCount ? `<a href="/app/voxtelesys-sms-log?links.link_name=${frm.docname}">${smsCount} ${__("SMS")}</a>` : ""}
|
||||||
|
</div>`,
|
||||||
|
__("Voxtelesys Activity")
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue