brotherton-erpnext/erpnext/public/js/call_popup/call_summary_dialog.js

110 lines
2.9 KiB
JavaScript
Raw Normal View History

2019-05-16 18:25:35 +00:00
class CallSummaryDialog {
2019-05-18 10:41:29 +00:00
constructor({ contact, call_payload, last_communication }) {
this.number = call_payload.CallFrom;
this.contact = contact;
this.last_communication = last_communication;
2019-05-16 18:25:35 +00:00
this.make();
}
make() {
2019-05-18 10:41:29 +00:00
this.dialog = new frappe.ui.Dialog({
'title': __(`Incoming call from ${this.contact ? this.contact.name : 'Unknown Number'}`),
'static': true,
'minimizable': true,
2019-05-16 18:25:35 +00:00
'fields': [{
'fieldname': 'customer_info',
'fieldtype': 'HTML'
}, {
'fieldtype': 'Section Break'
}, {
2019-05-18 10:41:29 +00:00
'fieldtype': 'Small Text',
2019-05-16 18:25:35 +00:00
'label': "Last Communication",
'fieldname': 'last_communication',
2019-05-18 10:41:29 +00:00
'read_only': true
2019-05-16 18:25:35 +00:00
}, {
'fieldtype': 'Column Break'
}, {
2019-05-18 10:41:29 +00:00
'fieldtype': 'Small Text',
2019-05-16 18:25:35 +00:00
'label': 'Call Summary',
'fieldname': 'call_communication',
'default': 'This is not working please helpppp',
"placeholder": __("Select or add new customer")
2019-05-18 10:41:29 +00:00
}, {
'fieldtype': 'Button',
'label': 'Submit',
'click': () => {
frappe.xcall()
}
2019-05-16 18:25:35 +00:00
}]
});
2019-05-18 10:41:29 +00:00
this.make_customer_contact();
this.dialog.show();
this.dialog.get_close_btn().show();
this.dialog.header.find('.indicator').removeClass('hidden').addClass('blue');
2019-05-16 18:25:35 +00:00
}
get_dialog_skeleton() {
return `
<div class="call-summary-body">
<div class="customer-info flex">
</div>
<div class="flex">
<div class="last-communication"></div>
<div class="call-summary"></div>
</div>
<hr>
<div class="flex">
<div class="section-right"></div>
<div class="section-left"></div>
</div>
</div>
`;
}
2019-05-18 10:41:29 +00:00
make_customer_contact() {
const wrapper = this.dialog.fields_dict["customer_info"].$wrapper;
const contact = this.contact;
const customer = this.contact.links ? this.contact.links[0] : null;
const customer_link = customer ? frappe.utils.get_form_link(customer.link_doctype, customer.link_name, true): '';
if (!contact) {
2019-05-16 18:25:35 +00:00
wrapper.append('<b>Unknown Contact</b>');
} else {
wrapper.append(`
2019-05-18 10:41:29 +00:00
<div class="customer-info flex">
<img src="${contact.image}">
<div class='flex-column'>
<span>${contact.first_name} ${contact.last_name}</span>
<span>${contact.mobile_no}</span>
${customer_link}
</div>
2019-05-16 18:25:35 +00:00
</div>
`);
}
}
make_last_communication_section() {
const last_communication_section = this.body.find('.last-communication');
const last_communication = frappe.ui.form.make_control({
parent: last_communication_section,
df: {
fieldtype: "Text",
label: "Last Communication",
fieldname: "last_communication",
'default': 'This is not working please helpppp',
"placeholder": __("Select or add new customer")
},
});
last_communication.set_value('This is not working please helpppp');
}
make_summary_section() {
//
}
}
2019-05-18 10:41:29 +00:00
$(document).on('app_ready', function () {
2019-05-16 18:25:35 +00:00
frappe.realtime.on('incoming_call', data => {
2019-05-18 10:41:29 +00:00
frappe.call_summary_dialog = new CallSummaryDialog(data);
2019-05-16 18:25:35 +00:00
});
});