fix(Issue): Time left and display only if Agreement exists (#17014)
* fix: time left and display only if agreement * fix: remove div if present * code refactor * use frappe.scrub * code formatting Co-Authored-By: hrwX <himanshuwarekar@yahoo.com> * remove unused fields * remove unsed return value
This commit is contained in:
parent
fa638443bc
commit
4d45ca08de
@ -1,7 +1,9 @@
|
||||
frappe.ui.form.on("Issue", {
|
||||
onload: function(frm) {
|
||||
frm.email_field = "raised_by";
|
||||
set_time_to_resolve_and_response(frm);
|
||||
if (frm.doc.service_level_agreement) {
|
||||
set_time_to_resolve_and_response(frm);
|
||||
}
|
||||
},
|
||||
|
||||
refresh: function (frm) {
|
||||
@ -84,15 +86,16 @@ function set_time_to_resolve_and_response(frm) {
|
||||
const email_account = frm.fields_dict['email_account'].$wrapper;
|
||||
|
||||
const time_to_respond = $(get_time_left_element(__('Time To Respond'), frm.doc.response_by));
|
||||
const time_to_resolve = $(get_time_left_element(__('Time To Resolve'), frm.doc.resolve_by));
|
||||
const time_to_resolve = $(get_time_left_element(__('Time To Resolve'), frm.doc.resolution_by));
|
||||
|
||||
time_to_respond.insertAfter(customer);
|
||||
time_to_resolve.insertAfter(email_account);
|
||||
}
|
||||
|
||||
function get_time_left_element(label, timestamp) {
|
||||
$('.'+ frappe.scrub(label) +'').remove();
|
||||
return `
|
||||
<div class="frappe-control input-max-width" data-field_name="${label.replace(/ /g, "_").toLowerCase()}">
|
||||
<div class="frappe-control input-max-width `+ frappe.scrub(label) +`" data-field_name="`+ frappe.scrub(label) +`">
|
||||
<div class="form-group">
|
||||
<div class="clearfix">
|
||||
<label class="control-label" style="padding-right: 0px;">
|
||||
@ -109,5 +112,5 @@ function get_time_left_element(label, timestamp) {
|
||||
|
||||
function get_time_left(timestamp) {
|
||||
const diff = moment(timestamp).diff(moment());
|
||||
return diff >= 44500 ? moment.duration().humanize() : 0;
|
||||
}
|
||||
return diff >= 44500 ? moment.duration(diff).humanize() : 0;
|
||||
}
|
||||
|
@ -128,8 +128,8 @@ class Issue(Document):
|
||||
|
||||
start_date_time = get_datetime(self.creation)
|
||||
|
||||
self.response_by, self.time_to_respond = get_expected_time_for('response', service_level, start_date_time)
|
||||
self.resolution_by, self.time_to_resolve = get_expected_time_for('resolution', service_level, start_date_time)
|
||||
self.response_by = get_expected_time_for('response', service_level, start_date_time)
|
||||
self.resolution_by = get_expected_time_for('resolution', service_level, start_date_time)
|
||||
|
||||
def get_expected_time_for(parameter, service_level, start_date_time):
|
||||
current_date_time = start_date_time
|
||||
@ -194,7 +194,7 @@ def get_expected_time_for(parameter, service_level, start_date_time):
|
||||
else:
|
||||
current_date_time = expected_time
|
||||
|
||||
return current_date_time, round(time_diff_in_hours(current_date_time, start_date_time), 2)
|
||||
return current_date_time
|
||||
|
||||
def get_list_context(context=None):
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user