From 2f0f704ddff275ada9e02688380d7f80a2b97787 Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Wed, 7 Feb 2018 11:46:17 +0100 Subject: [PATCH] Fixed issue #1322 - Customer response via note does not trigger escalation. --- .../app/controllers/ticket_zoom.coffee | 48 ++++++++++ test/browser/customer_ticket_create_test.rb | 87 +++++++++++++++++++ 2 files changed, 135 insertions(+) diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.coffee index 430a8b7d0..6365257de 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.coffee @@ -558,6 +558,10 @@ class App.TicketZoom extends App.Controller # update changes in ui currentStore = @currentStore() modelDiff = @formDiff(currentParams, currentStore) + + # set followup state if needed + @setDefaultFollowUpState(modelDiff, currentStore) + @markFormDiff(modelDiff) @taskUpdateAll(modelDiff) @@ -582,6 +586,43 @@ class App.TicketZoom extends App.Controller currentStore + setDefaultFollowUpState: (modelDiff, currentStore) -> + + # if the default state is set + # and the body get changed to empty + # then we want to reset the state + if @isDefaultFollowUpStateSet && !modelDiff.article.body + @$('.sidebar select[name=state_id]').val(currentStore.ticket.state_id).trigger('change') + @isDefaultFollowUpStateSet = false + return + + # set default if body is filled + return if !modelDiff.article.body + + # and state got not changed + return if modelDiff.ticket.state_id + + # and we are in the customer interface + return if !@permissionCheck('ticket.customer') + + # and the default is was not set before + return if @isDefaultFollowUpStateSet + + # prevent multiple changes for the default follow up state + @isDefaultFollowUpStateSet = true + + # get state + state = App.TicketState.findByAttribute('default_follow_up', true) + + # change ui and trigger change + if state + @$('.sidebar[data-tab=ticket] select[name=state_id]').val(state.id).trigger('change') + + true + + resetDefaultFollowUpState: -> + @isDefaultFollowUpStateSet = false + formCurrent: => currentParams = ticket: @formParam(@el.find('.edit')) @@ -596,6 +637,10 @@ class App.TicketZoom extends App.Controller # remove not needed attributes delete currentParams.article.form_id + + if @permissionCheck('ticket.customer') + currentParams.article.internal = '' + currentParams formDiff: (currentParams, currentStore) -> @@ -867,6 +912,9 @@ class App.TicketZoom extends App.Controller # reset task @taskReset() + # reset default follow up state + @resetDefaultFollowUpState() + # reset/delete uploaded attachments App.Ajax.request( type: 'DELETE' diff --git a/test/browser/customer_ticket_create_test.rb b/test/browser/customer_ticket_create_test.rb index e7f15f162..4e30c6c9a 100644 --- a/test/browser/customer_ticket_create_test.rb +++ b/test/browser/customer_ticket_create_test.rb @@ -64,5 +64,92 @@ class CustomerTicketCreateTest < TestCase css: '.content.active div.ticket-article', value: 'some body 1234 äöüß', ) + + # now we want to verify the default followup state + # for this case we close the ticket first and then + # write a new article. If the content is written + # then the state should change initially to open + + # close the ticket + select( + css: '.content.active [name="state_id"]', + value: 'closed', + ) + + set( + css: '.content.active [data-name="body"]', + value: 'close #1', + no_click: true, + ) + + click(css: '.content.active .js-submit') + watch_for( + css: '.content.active div.ticket-article', + value: 'close #1', + ) + + # check if the ticket is closed + match( + css: '.content.active .sidebar [name="state_id"]', + value: 'closed', + ) + + # type in new content into rte to trigger the default follow up state + set( + css: '.content.active [data-name="body"]', + value: 'some body blublub default followup for reopen check', + no_click: true, + ) + + # verify if the state has changed to open + watch_for( + css: '.content.active .sidebar [name="state_id"]', + value: 'open', + ) + + # no we verify the reverse way: + # if the body get changed to empty again then + # the default follow up state should get unset and + # will change to the the default ticket state. + + # remove content from rte + set( + css: '.content.active [data-name="body"]', + value: '', + no_click: true, + ) + + # check if state changed to closed again + watch_for( + css: '.content.active .sidebar [name="state_id"]', + value: 'closed', + ) + + # type in new content into rte to trigger the default follow up state + set( + css: '.content.active [data-name="body"]', + value: 'some body blublub default followup for reopen check', + no_click: true, + ) + + # verify if the state has changed to open + watch_for( + css: '.content.active .sidebar [name="state_id"]', + value: 'open', + ) + + # submit and reload to check if the new state is set + click(css: '.content.active .js-submit') + + watch_for( + css: '.content.active div.ticket-article', + value: 'some body blublub default followup for reopen check', + ) + + # verify if the state has changed to open + match( + css: '.content.active .sidebar [name="state_id"]', + value: 'open', + ) end end