fix: Improve call popup UX
- Close modal after 10 secs if user is has not entered any call summary
- Show alert once the summary was saved
diff --git a/.pylintrc b/.pylintrc
deleted file mode 100644
index 4b2ea0a..0000000
--- a/.pylintrc
+++ /dev/null
@@ -1 +0,0 @@
-disable=access-member-before-definition
\ No newline at end of file
diff --git a/erpnext/crm/doctype/lead/lead.js b/erpnext/crm/doctype/lead/lead.js
index 8c1ab2f..d2e907d 100644
--- a/erpnext/crm/doctype/lead/lead.js
+++ b/erpnext/crm/doctype/lead/lead.js
@@ -33,6 +33,7 @@
frappe.dynamic_link = { doc: doc, fieldname: 'name', doctype: 'Lead' }
if(!doc.__islocal && doc.__onload && !doc.__onload.is_customer) {
+ this.frm.add_custom_button(__("Call"), this.call);
this.frm.add_custom_button(__("Customer"), this.create_customer, __('Create'));
this.frm.add_custom_button(__("Opportunity"), this.create_opportunity, __('Create'));
this.frm.add_custom_button(__("Quotation"), this.make_quotation, __('Create'));
@@ -52,6 +53,14 @@
})
},
+ call: () => {
+ frappe.xcall('erpnext.erpnext_integrations.exotel_integration.make_a_call', {
+ 'to_number': this.frm.doc.phone,
+ 'from_number': '<nam>',
+ 'caller_id': '09513886363'
+ }).then(console.log)
+ },
+
create_opportunity: function () {
frappe.model.open_mapped_doc({
method: "erpnext.crm.doctype.lead.lead.make_opportunity",
diff --git a/erpnext/public/js/call_popup/call_popup.js b/erpnext/public/js/call_popup/call_popup.js
index a15c37c..4fd3a55 100644
--- a/erpnext/public/js/call_popup/call_popup.js
+++ b/erpnext/public/js/call_popup/call_popup.js
@@ -35,15 +35,19 @@
'fieldname': 'call_summary',
}, {
'fieldtype': 'Button',
- 'label': 'Submit',
+ 'label': 'Save',
'click': () => {
- const values = this.dialog.get_values();
- if (!values.call_summary) return;
+ const call_summary = this.dialog.get_value('call_summary');
+ if (!call_summary) return;
frappe.xcall('erpnext.crm.doctype.utils.add_call_summary', {
'docname': this.call_log.id,
- 'summary': values.call_summary,
+ 'summary': call_summary,
}).then(() => {
- this.dialog.set_value('call_summary', '');
+ this.close_modal();
+ frappe.show_alert({
+ message: `${__('Call Summary Saved')}<br><a class="text-small text-muted" href="#Form/Call Log/${this.call_log.name}">${__('View call log')}</a>`,
+ indicator: 'green'
+ });
});
}
}],
@@ -52,10 +56,7 @@
this.make_caller_info_section();
this.dialog.get_close_btn().show();
this.dialog.$body.addClass('call-popup');
- this.dialog.set_secondary_action(() => {
- delete erpnext.call_popup;
- this.dialog.hide();
- });
+ this.dialog.set_secondary_action(this.close_modal);
frappe.utils.play_sound("incoming-call");
this.dialog.show();
}
@@ -71,7 +72,7 @@
if (!contact) {
wrapper.append(`
<div class="caller-info">
- <div>Unknown Number: <b>${this.caller_number}</b></div>
+ <div>${__('Unknown Number')}: <b>${this.caller_number}</b></div>
<a class="contact-link" href="#Form/Contact/New Contact?phone=${this.caller_number}">
${__('Create New Contact')}
</a>
@@ -131,10 +132,19 @@
this.set_call_status();
}
+ close_modal() {
+ delete erpnext.call_popup;
+ this.dialog.hide();
+ }
+
call_disconnected(call_log) {
frappe.utils.play_sound("call-disconnect");
this.update_call_log(call_log);
- setTimeout(this.get_close_btn().click, 10000);
+ setTimeout(() => {
+ if (!this.dialog.get_value('call_summary')) {
+ this.close_modal();
+ }
+ }, 10000);
}
make_last_interaction_section() {
@@ -145,14 +155,12 @@
const comm_field = this.dialog.fields_dict["last_communication"];
if (data.last_communication) {
const comm = data.last_communication;
- // this.dialog.set_df_property('last_interaction', 'hidden', false);
comm_field.set_value(comm.content);
comm_field.$wrapper.append(frappe.utils.get_form_link('Communication', comm.name));
}
if (data.last_issue) {
const issue = data.last_issue;
- // this.dialog.set_df_property('last_interaction', 'hidden', false);
const issue_field = this.dialog.fields_dict["last_issue"];
issue_field.set_value(issue.subject);
issue_field.$wrapper.append(`<a class="text-medium" href="#List/Issue?customer=${issue.customer}">