From a6e34ddcd8100dbdba4d25c6a757d0a46f88723b Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 15 Sep 2015 23:42:08 +0200 Subject: [PATCH] Improved sla time selection. --- .../_ui_element/sla_times.js.coffee | 31 ++++++++--- .../javascripts/app/models/sla.js.coffee | 2 +- .../app/views/generic/sla_times.jst.eco | 32 ++++++++++++ .../javascripts/app/views/sla/index.jst.eco | 51 +++++++++++++++++++ 4 files changed, 109 insertions(+), 7 deletions(-) create mode 100644 app/assets/javascripts/app/views/generic/sla_times.jst.eco create mode 100644 app/assets/javascripts/app/views/sla/index.jst.eco diff --git a/app/assets/javascripts/app/controllers/_ui_element/sla_times.js.coffee b/app/assets/javascripts/app/controllers/_ui_element/sla_times.js.coffee index 4ebe5febf..31f3f4066 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/sla_times.js.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/sla_times.js.coffee @@ -5,21 +5,40 @@ class App.UiElement.sla_times attribute: attribute first_response_time: params.first_response_time update_time: params.update_time - close_time: params.close_time + solution_time: params.solution_time first_response_time_in_text: @toText(params.first_response_time) update_time_in_text: @toText(params.update_time) - close_time_in_text: @toText(params.close_time) + solution_time_in_text: @toText(params.solution_time) ) ) + item.find('.js-activateRow').bind('change', (e) => + element = $(e.target) + if element.prop('checked') + element.closest('tr').addClass('is-active') + else + element.closest('tr').removeClass('is-active') + element.closest('tr').find('.js-timeConvertFrom').val('') + ) + item.find('.js-timeConvertFrom').bind('keyup', (e) => - inText = $(e.target).val() + element = $(e.target) + inText = element.val() inMinutes = @toMinutes(inText) if !inMinutes - $(e.target).addClass('has-error') + element.addClass('has-error') else - $(e.target).removeClass('has-error') - dest = $(e.target).closest('td').find('.js-timeConvertTo') + element.removeClass('has-error') + dest = element.closest('td').find('.js-timeConvertTo') dest.val(inMinutes) + element.closest('tr').find('.js-activateRow').prop('checked', true) + element.closest('tr').addClass('is-active') + ) + + item.find('.js-timeConvertFrom').each(-> + if $(@).val() + $(@).closest('tr').find('.js-activateRow').prop('checked', true) + else + $(@).closest('tr').find('.js-activateRow').prop('checked', false) ) item diff --git a/app/assets/javascripts/app/models/sla.js.coffee b/app/assets/javascripts/app/models/sla.js.coffee index d3d334b4a..102fa0992 100644 --- a/app/assets/javascripts/app/models/sla.js.coffee +++ b/app/assets/javascripts/app/models/sla.js.coffee @@ -1,5 +1,5 @@ class App.Sla extends App.Model - @configure 'Sla', 'name', 'first_response_time', 'update_time', 'close_time', 'condition', 'calendar_id' + @configure 'Sla', 'name', 'first_response_time', 'update_time', 'solution_time', 'condition', 'calendar_id' @extend Spine.Model.Ajax @url: @apiPath + '/slas' @configure_attributes = [ diff --git a/app/assets/javascripts/app/views/generic/sla_times.jst.eco b/app/assets/javascripts/app/views/generic/sla_times.jst.eco new file mode 100644 index 000000000..233c56262 --- /dev/null +++ b/app/assets/javascripts/app/views/generic/sla_times.jst.eco @@ -0,0 +1,32 @@ + + + + + + + + + + + + + +
<%- @T('Active') %> + <%- @T('Type') %> + <%- @T('Time') %> <%- @T('in hours') %> +
+ + +

<%- @T('Timeframe for the first response.') %>

+
+
+ + +

<%- @T('Timeframe for every following response.') %>

+
+
+ + +

<%- @T('Timeframe for solving the problem.') %>

+
+
\ No newline at end of file diff --git a/app/assets/javascripts/app/views/sla/index.jst.eco b/app/assets/javascripts/app/views/sla/index.jst.eco new file mode 100644 index 000000000..d961711f1 --- /dev/null +++ b/app/assets/javascripts/app/views/sla/index.jst.eco @@ -0,0 +1,51 @@ + + +<% if _.isEmpty(@slas): %> +<%- @description %> +<% end %> + +<% for sla in @slas: %> +
+
+
+

<%= sla.name %>

+
+
+
+
+

<%- @T('Filter') %>

+ <% for rule in sla.rules: %> + <%- rule %>
+ <% end %> +
+ +
+

<%- @T('Escalation Times') %>

+ <% if sla.first_response_time: %> + <%- sla.first_response_time_in_text %> <%- @T('hours') %> - <%- @T('First Response Time') %>
+ <% end %> + <% if sla.update_time: %> + <%- sla.update_time_in_text %> <%- @T('hours') %> - <%- @T('Update Time') %>
+ <% end %> + <% if sla.solution_time: %> + <%- sla.solution_time_in_text %> <%- @T('hours') %> - <%- @T('Solution Time') %> + <% end %> +
+
+
<%- @T('Delete') %>
+
<%- @T('Edit') %>
+
+
+
+<% end %>