mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-04 12:49:10 +00:00
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
This commit is contained in:
@@ -33,6 +33,7 @@ erpnext.LeadController = frappe.ui.form.Controller.extend({
|
|||||||
frappe.dynamic_link = { doc: doc, fieldname: 'name', doctype: 'Lead' }
|
frappe.dynamic_link = { doc: doc, fieldname: 'name', doctype: 'Lead' }
|
||||||
|
|
||||||
if(!doc.__islocal && doc.__onload && !doc.__onload.is_customer) {
|
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(__("Customer"), this.create_customer, __('Create'));
|
||||||
this.frm.add_custom_button(__("Opportunity"), this.create_opportunity, __('Create'));
|
this.frm.add_custom_button(__("Opportunity"), this.create_opportunity, __('Create'));
|
||||||
this.frm.add_custom_button(__("Quotation"), this.make_quotation, __('Create'));
|
this.frm.add_custom_button(__("Quotation"), this.make_quotation, __('Create'));
|
||||||
@@ -52,6 +53,14 @@ erpnext.LeadController = frappe.ui.form.Controller.extend({
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
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 () {
|
create_opportunity: function () {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.crm.doctype.lead.lead.make_opportunity",
|
method: "erpnext.crm.doctype.lead.lead.make_opportunity",
|
||||||
|
|||||||
@@ -35,15 +35,19 @@ class CallPopup {
|
|||||||
'fieldname': 'call_summary',
|
'fieldname': 'call_summary',
|
||||||
}, {
|
}, {
|
||||||
'fieldtype': 'Button',
|
'fieldtype': 'Button',
|
||||||
'label': 'Submit',
|
'label': 'Save',
|
||||||
'click': () => {
|
'click': () => {
|
||||||
const values = this.dialog.get_values();
|
const call_summary = this.dialog.get_value('call_summary');
|
||||||
if (!values.call_summary) return;
|
if (!call_summary) return;
|
||||||
frappe.xcall('erpnext.crm.doctype.utils.add_call_summary', {
|
frappe.xcall('erpnext.crm.doctype.utils.add_call_summary', {
|
||||||
'docname': this.call_log.id,
|
'docname': this.call_log.id,
|
||||||
'summary': values.call_summary,
|
'summary': call_summary,
|
||||||
}).then(() => {
|
}).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 @@ class CallPopup {
|
|||||||
this.make_caller_info_section();
|
this.make_caller_info_section();
|
||||||
this.dialog.get_close_btn().show();
|
this.dialog.get_close_btn().show();
|
||||||
this.dialog.$body.addClass('call-popup');
|
this.dialog.$body.addClass('call-popup');
|
||||||
this.dialog.set_secondary_action(() => {
|
this.dialog.set_secondary_action(this.close_modal);
|
||||||
delete erpnext.call_popup;
|
|
||||||
this.dialog.hide();
|
|
||||||
});
|
|
||||||
frappe.utils.play_sound("incoming-call");
|
frappe.utils.play_sound("incoming-call");
|
||||||
this.dialog.show();
|
this.dialog.show();
|
||||||
}
|
}
|
||||||
@@ -71,7 +72,7 @@ class CallPopup {
|
|||||||
if (!contact) {
|
if (!contact) {
|
||||||
wrapper.append(`
|
wrapper.append(`
|
||||||
<div class="caller-info">
|
<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}">
|
<a class="contact-link" href="#Form/Contact/New Contact?phone=${this.caller_number}">
|
||||||
${__('Create New Contact')}
|
${__('Create New Contact')}
|
||||||
</a>
|
</a>
|
||||||
@@ -131,10 +132,19 @@ class CallPopup {
|
|||||||
this.set_call_status();
|
this.set_call_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
close_modal() {
|
||||||
|
delete erpnext.call_popup;
|
||||||
|
this.dialog.hide();
|
||||||
|
}
|
||||||
|
|
||||||
call_disconnected(call_log) {
|
call_disconnected(call_log) {
|
||||||
frappe.utils.play_sound("call-disconnect");
|
frappe.utils.play_sound("call-disconnect");
|
||||||
this.update_call_log(call_log);
|
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() {
|
make_last_interaction_section() {
|
||||||
@@ -145,14 +155,12 @@ class CallPopup {
|
|||||||
const comm_field = this.dialog.fields_dict["last_communication"];
|
const comm_field = this.dialog.fields_dict["last_communication"];
|
||||||
if (data.last_communication) {
|
if (data.last_communication) {
|
||||||
const comm = 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.set_value(comm.content);
|
||||||
comm_field.$wrapper.append(frappe.utils.get_form_link('Communication', comm.name));
|
comm_field.$wrapper.append(frappe.utils.get_form_link('Communication', comm.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.last_issue) {
|
if (data.last_issue) {
|
||||||
const issue = 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"];
|
const issue_field = this.dialog.fields_dict["last_issue"];
|
||||||
issue_field.set_value(issue.subject);
|
issue_field.set_value(issue.subject);
|
||||||
issue_field.$wrapper.append(`<a class="text-medium" href="#List/Issue?customer=${issue.customer}">
|
issue_field.$wrapper.append(`<a class="text-medium" href="#List/Issue?customer=${issue.customer}">
|
||||||
|
|||||||
Reference in New Issue
Block a user