refactor: dashboard indicator when SLA is on hold

This commit is contained in:
Rucha Mahabal 2020-06-05 16:36:31 +05:30
parent 2c9f7cf371
commit 8d39928418

View File

@ -38,22 +38,35 @@ frappe.ui.form.on("Issue", {
}, },
refresh: function (frm) { refresh: function (frm) {
if (frm.doc.status !== "Closed" && frm.doc.agreement_fulfilled === "Ongoing") { if (frm.doc.status !== "Closed" && frm.doc.agreement_fulfilled === "Ongoing") {
if (frm.doc.service_level_agreement) { if (frm.doc.service_level_agreement) {
if (frm.doc.status == "Replied") { frappe.call({
frm.dashboard.clear_headline(); 'method': 'frappe.client.get',
let message = {"indicator": "orange", "msg": __("Replied {0}", [frappe.datetime.comment_when(frm.doc.on_hold_since)])}; args: {
frm.dashboard.set_headline_alert( doctype: 'Support Settings',
'<div class="row">' + name: 'Support Settings'
'<div class="col-xs-12">' + },
'<span class="indicator whitespace-nowrap '+ message.indicator +'"><span>'+ message.msg +'</span></span> ' + callback: function(data) {
'</div>' + let statuses = data.message.pause_sla_on_status;
'</div>' const hold_statuses = [];
); $.each(statuses, (_i, entry) => {
} else { hold_statuses.push(entry.status);
set_time_to_resolve_and_response(frm); });
} if (hold_statuses.includes(frm.doc.status)) {
frm.dashboard.clear_headline();
let message = {"indicator": "orange", "msg": __("SLA is on hold since {0}", [moment(frm.doc.on_hold_since).fromNow(true)])};
frm.dashboard.set_headline_alert(
'<div class="row">' +
'<div class="col-xs-12">' +
'<span class="indicator whitespace-nowrap '+ message.indicator +'"><span>'+ message.msg +'</span></span> ' +
'</div>' +
'</div>'
);
} else {
set_time_to_resolve_and_response(frm);
}
}
});
} }
frm.add_custom_button(__("Close"), function () { frm.add_custom_button(__("Close"), function () {
@ -67,6 +80,7 @@ frappe.ui.form.on("Issue", {
frm: frm frm: frm
}); });
}, __("Make")); }, __("Make"));
} else { } else {
if (frm.doc.service_level_agreement) { if (frm.doc.service_level_agreement) {
frm.dashboard.clear_headline(); frm.dashboard.clear_headline();