Fixes #3837 - Wrong escalation update time in admin interface is shown
This commit is contained in:
parent
59ecff9274
commit
1d2549b41f
3 changed files with 48 additions and 7 deletions
|
@ -36,22 +36,38 @@ App.ViewHelpers =
|
||||||
App.Utils.decimal(data, positions)
|
App.Utils.decimal(data, positions)
|
||||||
|
|
||||||
# define time_duration / mm:ss / hh:mm:ss format helper
|
# define time_duration / mm:ss / hh:mm:ss format helper
|
||||||
time_duration: (time, show_seconds = true) ->
|
time_duration: (time) ->
|
||||||
return '' if !time
|
return '' if !time
|
||||||
return '' if isNaN(parseInt(time))
|
return '' if isNaN(parseInt(time))
|
||||||
|
|
||||||
# Hours, minutes and seconds
|
# Hours, minutes and seconds
|
||||||
hrs = ~~parseInt((time / 3600))
|
hrs = ~~parseInt((time / 3600))
|
||||||
mins = ~~parseInt(((time % 3600) / 60))
|
mins = ~~parseInt(((time % 3600) / 60))
|
||||||
secs = parseInt(time % 60)
|
secs = parseInt(time % 60)
|
||||||
|
|
||||||
# Output like "1:01" or "4:03:59" or "123:03:59"
|
# Output like "1:01" or "4:03:59" or "123:03:59"
|
||||||
mins = "0#{mins}" if mins < 10
|
mins = "0#{mins}" if mins < 10
|
||||||
secs = "0#{secs}" if secs < 10
|
secs = "0#{secs}" if secs < 10
|
||||||
if hrs > 0 && show_seconds
|
|
||||||
|
if hrs > 0
|
||||||
return "#{hrs}:#{mins}:#{secs}"
|
return "#{hrs}:#{mins}:#{secs}"
|
||||||
|
|
||||||
"#{mins}:#{secs}"
|
"#{mins}:#{secs}"
|
||||||
|
|
||||||
|
# define time_duration / hh:mm
|
||||||
|
time_duration_hh_mm: (time_in_minutes) ->
|
||||||
|
return '' if !time_in_minutes
|
||||||
|
return '' if isNaN(parseInt(time_in_minutes))
|
||||||
|
|
||||||
|
# Hours, minutes and seconds
|
||||||
|
hrs = ~~parseInt((time_in_minutes / 60))
|
||||||
|
mins = ~~parseInt((time_in_minutes % 60))
|
||||||
|
|
||||||
|
hrs = "0#{hrs}" if hrs < 10
|
||||||
|
mins = "0#{mins}" if mins < 10
|
||||||
|
|
||||||
|
"#{hrs}:#{mins}"
|
||||||
|
|
||||||
# define mask helper
|
# define mask helper
|
||||||
# mask an value like 'a***********yz'
|
# mask an value like 'a***********yz'
|
||||||
M: (item, start = 1, end = 2) ->
|
M: (item, start = 1, end = 2) ->
|
||||||
|
|
|
@ -34,19 +34,19 @@
|
||||||
<div class="action-block action-block--flex">
|
<div class="action-block action-block--flex">
|
||||||
<div class="label"><%- @T('Escalation Times') %></div>
|
<div class="label"><%- @T('Escalation Times') %></div>
|
||||||
<% if sla.first_response_time: %>
|
<% if sla.first_response_time: %>
|
||||||
<%- @time_duration(sla.first_response_time, false) %> <%- @T('hours') %> - <%- @T('First Response Time') %>
|
<%- @time_duration_hh_mm(sla.first_response_time) %> <%- @T('hours') %> - <%- @T('First Response Time') %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if sla.response_time: %>
|
<% if sla.response_time: %>
|
||||||
<br>
|
<br>
|
||||||
<%- @time_duration(sla.response_time, false) %> <%- @T('hours') %> - <%- @T('Response Time') %>
|
<%- @time_duration_hh_mm(sla.response_time) %> <%- @T('hours') %> - <%- @T('Response Time') %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if sla.update_time: %>
|
<% if sla.update_time: %>
|
||||||
<br>
|
<br>
|
||||||
<%- @time_duration(sla.update_time, false) %> <%- @T('hours') %> - <%- @T('Update Time') %>
|
<%- @time_duration_hh_mm(sla.update_time) %> <%- @T('hours') %> - <%- @T('Update Time') %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if sla.solution_time: %>
|
<% if sla.solution_time: %>
|
||||||
<br>
|
<br>
|
||||||
<%- @time_duration(sla.solution_time, false) %> <%- @T('hours') %> - <%- @T('Solution Time') %>
|
<%- @time_duration_hh_mm(sla.solution_time) %> <%- @T('hours') %> - <%- @T('Solution Time') %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<br>
|
<br>
|
||||||
</div>
|
</div>
|
||||||
|
|
25
public/assets/tests/qunit/view_helpers.js
Normal file
25
public/assets/tests/qunit/view_helpers.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
QUnit.test("time_duration_hh_mm", assert => {
|
||||||
|
let func = App.ViewHelpers.time_duration_hh_mm
|
||||||
|
assert.equal(func(1), '00:01')
|
||||||
|
|
||||||
|
assert.equal(func(61), '01:01')
|
||||||
|
|
||||||
|
assert.equal(func(3600), '60:00')
|
||||||
|
|
||||||
|
assert.equal(func(7200), '120:00')
|
||||||
|
})
|
||||||
|
|
||||||
|
QUnit.test("time_duration", assert => {
|
||||||
|
let func = App.ViewHelpers.time_duration
|
||||||
|
assert.equal(func(1), '00:01')
|
||||||
|
|
||||||
|
assert.equal(func(61), '01:01')
|
||||||
|
|
||||||
|
assert.equal(func(3600), '1:00:00')
|
||||||
|
|
||||||
|
assert.equal(func(7200), '2:00:00')
|
||||||
|
|
||||||
|
assert.equal(func(36000), '10:00:00')
|
||||||
|
|
||||||
|
assert.equal(func(360101), '100:01:41')
|
||||||
|
})
|
Loading…
Reference in a new issue