Fixes #3837 - Wrong escalation update time in admin interface is shown
This commit is contained in:
parent
86671d5eaf
commit
86ded71621
6 changed files with 66 additions and 7 deletions
|
@ -36,22 +36,38 @@ App.ViewHelpers =
|
|||
App.Utils.decimal(data, positions)
|
||||
|
||||
# define time_duration / mm:ss / hh:mm:ss format helper
|
||||
time_duration: (time, show_seconds = true) ->
|
||||
time_duration: (time) ->
|
||||
return '' if !time
|
||||
return '' if isNaN(parseInt(time))
|
||||
|
||||
# Hours, minutes and seconds
|
||||
hrs = ~~parseInt((time / 3600))
|
||||
hrs = ~~parseInt((time / 3600))
|
||||
mins = ~~parseInt(((time % 3600) / 60))
|
||||
secs = parseInt(time % 60)
|
||||
|
||||
# Output like "1:01" or "4:03:59" or "123:03:59"
|
||||
mins = "0#{mins}" if mins < 10
|
||||
secs = "0#{secs}" if secs < 10
|
||||
if hrs > 0 && show_seconds
|
||||
|
||||
if hrs > 0
|
||||
return "#{hrs}:#{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
|
||||
# mask an value like 'a***********yz'
|
||||
M: (item, start = 1, end = 2) ->
|
||||
|
|
|
@ -34,19 +34,19 @@
|
|||
<div class="action-block action-block--flex">
|
||||
<div class="label"><%- @T('Escalation Times') %></div>
|
||||
<% 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 %>
|
||||
<% if sla.response_time: %>
|
||||
<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 %>
|
||||
<% if sla.update_time: %>
|
||||
<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 %>
|
||||
<% if sla.solution_time: %>
|
||||
<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 %>
|
||||
<br>
|
||||
</div>
|
||||
|
|
13
app/views/tests/view_helpers.html.erb
Normal file
13
app/views/tests/view_helpers.html.erb
Normal file
|
@ -0,0 +1,13 @@
|
|||
<link rel="stylesheet" href="/assets/tests/qunit-1.21.0.css">
|
||||
<%= javascript_include_tag "/assets/tests/qunit-1.21.0.js", "/assets/tests/view_helpers.js", nonce: true %>
|
||||
|
||||
<style type="text/css">
|
||||
body {
|
||||
padding-top: 0px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<%= javascript_tag nonce: true do -%>
|
||||
<% end -%>
|
||||
|
||||
<div id="qunit" class="u-dontfold"></div>
|
|
@ -37,6 +37,7 @@ Zammad::Application.routes.draw do
|
|||
match '/tests_text_module', to: 'tests#text_module', via: :get
|
||||
match '/tests_color_object', to: 'tests#color_object', via: :get
|
||||
match '/tests_kb_video_embeding', to: 'tests#kb_video_embeding', via: :get
|
||||
match '/tests_view_helpers', to: 'tests#view_helpers', via: :get
|
||||
match '/tests/wait/:sec', to: 'tests#wait', via: :get
|
||||
match '/tests/raised_exception', to: 'tests#error_raised_exception', via: :get
|
||||
|
||||
|
|
25
public/assets/tests/view_helpers.js
Normal file
25
public/assets/tests/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')
|
||||
})
|
|
@ -68,6 +68,10 @@ RSpec.describe 'QUnit', type: :system, authenticated_as: false, set_up: true, we
|
|||
it 'Image Service' do
|
||||
q_unit_tests('image_service')
|
||||
end
|
||||
|
||||
it 'View helpers' do
|
||||
q_unit_tests('view_helpers')
|
||||
end
|
||||
end
|
||||
|
||||
context 'Form' do
|
||||
|
|
Loading…
Reference in a new issue