v2.1: settings SMS fields + HD Ticket/Contact/Lead form JS: voxtelesys_settings.js
This commit is contained in:
parent
4d7e30a6a5
commit
cdcb621a91
1 changed files with 31 additions and 11 deletions
|
|
@ -1,21 +1,35 @@
|
||||||
frappe.ui.form.on("Voxtelesys Settings", {
|
frappe.ui.form.on("Voxtelesys Settings", {
|
||||||
refresh(frm) {
|
refresh(frm) {
|
||||||
frm.set_df_property("webhook_url_display", "read_only", 1);
|
frm.set_df_property("webhook_url_display", "read_only", 1);
|
||||||
if (!frm.doc.webhook_url_display) {
|
frm.set_df_property("sms_webhook_url_display", "read_only", 1);
|
||||||
const base = frm.doc.voxml_base_url || `${window.location.protocol}//${window.location.host}`;
|
if (!frm.doc.webhook_url_display || !frm.doc.sms_webhook_url_display) {
|
||||||
frm.set_value("webhook_url_display",
|
const base =
|
||||||
`${base}/api/method/voxtelesys_integration.api.voxtelesys.handle_inbound_call`);
|
(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"), () => {
|
frm.add_custom_button(__("Test API Connection"), () => {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "voxtelesys_integration.api.voxtelesys.test_connection",
|
method: "voxtelesys_integration.api.voxtelesys.test_connection",
|
||||||
callback(r) {
|
callback(r) {
|
||||||
if (r.message && r.message.ok) {
|
if (r.message && r.message.ok) {
|
||||||
frappe.msgprint({ title: __("Connection Successful"),
|
frappe.msgprint({
|
||||||
message: __("Voxtelesys API responded correctly."), indicator: "green" });
|
title: __("Connection Successful"),
|
||||||
|
message: __("Voxtelesys Voice API responded correctly."),
|
||||||
|
indicator: "green",
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
frappe.msgprint({ title: __("Connection Failed"),
|
frappe.msgprint({
|
||||||
message: r.message?.error || __("Could not reach Voxtelesys API."), indicator: "red" });
|
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) {
|
voxml_base_url(frm) {
|
||||||
const base = (frm.doc.voxml_base_url || "").replace(/\/$/, "");
|
const base = (frm.doc.voxml_base_url || "").replace(/\/$/, "");
|
||||||
frm.set_value("webhook_url_display",
|
frm.set_value(
|
||||||
`${base}/api/method/voxtelesys_integration.api.voxtelesys.handle_inbound_call`);
|
"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`
|
||||||
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue