From b70b530e2a1167a84784edf47beaef784bad695e Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 6 Feb 2017 00:15:28 +0100 Subject: [PATCH] Fixed issue #705 - Time accounting works only with dot. Fixed issue #670 - Auto Focus on "Time Accounting" Popupbox. --- .../_application_controller.coffee | 2 + .../ticket_zoom/time_accounting.coffee | 35 +++- .../javascripts/app/views/modal.jst.eco | 8 +- script/build/test_slice_tests.sh | 6 + .../agent_ticket_time_accounting_test.rb | 156 ++++++++++++++++++ 5 files changed, 202 insertions(+), 5 deletions(-) create mode 100644 test/browser/agent_ticket_time_accounting_test.rb diff --git a/app/assets/javascripts/app/controllers/_application_controller.coffee b/app/assets/javascripts/app/controllers/_application_controller.coffee index 8a598e2d6..f973d0e79 100644 --- a/app/assets/javascripts/app/controllers/_application_controller.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller.coffee @@ -678,6 +678,7 @@ class App.ControllerModal extends App.Controller container: null buttonClass: 'btn--success' centerButtons: [] + leftButtons: [] buttonClose: true buttonCancel: false buttonCancelClass: 'btn--text btn--subtle' @@ -729,6 +730,7 @@ class App.ControllerModal extends App.Controller buttonSubmit: @buttonSubmit buttonClass: @buttonClass centerButtons: @centerButtons + leftButtons: @leftButtons ) modal.find('.modal-body').html content if !@initRenderingDone diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/time_accounting.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/time_accounting.coffee index ae7df3cda..87f1307bb 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/time_accounting.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/time_accounting.coffee @@ -1,20 +1,47 @@ class App.TicketZoomTimeAccounting extends App.ControllerModal buttonClose: true - buttonCancel: 'skip' + buttonCancel: false buttonSubmit: 'Account Time' buttonClass: 'btn--success' + leftButtons: [{ + className: 'btn--text btn--subtle js-skip', + text: 'skip' + }] head: 'Time Accounting' small: true + events: + 'submit form': 'submit' + 'click .js-submit:not(.is-disabled)': 'submit' + 'click .js-cancel': 'cancel' + 'click .js-close': 'cancel' + 'click .js-skip': 'skip' + content: -> App.view('ticket_zoom/time_accounting')() + onShown: => + @$('[name="time_unit"]').focus() + + skip: (e) => + return if !@submitCallback + @submitCallback({}) + @close(e) + onCancel: => - if @cancelCallback - @cancelCallback() + return if !@cancelCallback + @cancelCallback() onSubmit: => + @$('[name="time_unit"]').removeClass('has-error') + params = @formParams() + if params.time_unit + params.time_unit = params.time_unit.replace(',', '.') + + if isNaN(parseFloat(params.time_unit)) || params.time_unit.match(/[A-z]|\s/) + @$('[name="time_unit"]').addClass('has-error') + return + @close() if @submitCallback - params = @formParams() @submitCallback(params) diff --git a/app/assets/javascripts/app/views/modal.jst.eco b/app/assets/javascripts/app/views/modal.jst.eco index 67d0145b3..b3d12f4b8 100644 --- a/app/assets/javascripts/app/views/modal.jst.eco +++ b/app/assets/javascripts/app/views/modal.jst.eco @@ -15,8 +15,14 @@