v2.1: settings SMS fields + HD Ticket/Contact/Lead form JS: voxtelesys_settings.js

This commit is contained in:
Zac Gaetano 2026-05-12 00:12:51 -04:00
parent 4d7e30a6a5
commit cdcb621a91

View file

@ -1,21 +1,35 @@
frappe.ui.form.on("Voxtelesys Settings", {
refresh(frm) {
frm.set_df_property("webhook_url_display", "read_only", 1);
if (!frm.doc.webhook_url_display) {
const base = frm.doc.voxml_base_url || `${window.location.protocol}//${window.location.host}`;
frm.set_value("webhook_url_display",
`${base}/api/method/voxtelesys_integration.api.voxtelesys.handle_inbound_call`);
frm.set_df_property("sms_webhook_url_display", "read_only", 1);
if (!frm.doc.webhook_url_display || !frm.doc.sms_webhook_url_display) {
const base =
(frm.doc.voxml_base_url || `${window.location.protocol}//${window.location.host}`).replace(/\/$/, "");
frm.set_value(
"webhook_url_display",
`${base}/api/method/voxtelesys_integration.api.voxtelesys.handle_inbound_call`
);
frm.set_value(
"sms_webhook_url_display",
`${base}/api/method/voxtelesys_integration.api.sms.handle_inbound_sms`
);
}
frm.add_custom_button(__("Test API Connection"), () => {
frappe.call({
method: "voxtelesys_integration.api.voxtelesys.test_connection",
callback(r) {
if (r.message && r.message.ok) {
frappe.msgprint({ title: __("Connection Successful"),
message: __("Voxtelesys API responded correctly."), indicator: "green" });
frappe.msgprint({
title: __("Connection Successful"),
message: __("Voxtelesys Voice API responded correctly."),
indicator: "green",
});
} else {
frappe.msgprint({ title: __("Connection Failed"),
message: r.message?.error || __("Could not reach Voxtelesys API."), indicator: "red" });
frappe.msgprint({
title: __("Connection Failed"),
message: r.message?.error || __("Could not reach Voxtelesys API."),
indicator: "red",
});
}
},
});
@ -23,7 +37,13 @@ frappe.ui.form.on("Voxtelesys Settings", {
},
voxml_base_url(frm) {
const base = (frm.doc.voxml_base_url || "").replace(/\/$/, "");
frm.set_value("webhook_url_display",
`${base}/api/method/voxtelesys_integration.api.voxtelesys.handle_inbound_call`);
frm.set_value(
"webhook_url_display",
`${base}/api/method/voxtelesys_integration.api.voxtelesys.handle_inbound_call`
);
frm.set_value(
"sms_webhook_url_display",
`${base}/api/method/voxtelesys_integration.api.sms.handle_inbound_sms`
);
},
});
});