Fixes #3837 - Wrong escalation update time in admin interface is shown

This commit is contained in:
Mantas 2021-11-07 20:37:01 +02:00
parent 86671d5eaf
commit 86ded71621
6 changed files with 66 additions and 7 deletions

View file

@ -36,7 +36,7 @@ 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))
@ -48,10 +48,26 @@ App.ViewHelpers =
# 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) ->

View file

@ -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>

View 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>

View file

@ -37,6 +37,7 @@ Zammad::Application.routes.draw do
match '/tests_text_module', to: 'tests#text_module', via: :get match '/tests_text_module', to: 'tests#text_module', via: :get
match '/tests_color_object', to: 'tests#color_object', 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_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/wait/:sec', to: 'tests#wait', via: :get
match '/tests/raised_exception', to: 'tests#error_raised_exception', via: :get match '/tests/raised_exception', to: 'tests#error_raised_exception', via: :get

View 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')
})

View file

@ -68,6 +68,10 @@ RSpec.describe 'QUnit', type: :system, authenticated_as: false, set_up: true, we
it 'Image Service' do it 'Image Service' do
q_unit_tests('image_service') q_unit_tests('image_service')
end end
it 'View helpers' do
q_unit_tests('view_helpers')
end
end end
context 'Form' do context 'Form' do