diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee index c6f6f9e88..2e508a65c 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee @@ -150,14 +150,6 @@ class App.TicketZoom extends App.Controller if !@editWidget || _.isEmpty( App.TaskManager.get(@task_key).state ) @editWidget = @Edit() - # show text module UI - if !@isRole('Customer') - new App.WidgetTextModule( - el: @el.find('textarea') - data: - ticket: @ticket - ) - # scroll to article if given if @article_id && document.getElementById( 'article-' + @article_id ) offset = document.getElementById( 'article-' + @article_id ).offsetTop @@ -324,6 +316,8 @@ class Edit extends App.Controller release: => @autosaveStop() + if @subscribeIdTextModule + App.Ticket.unsubscribe(@subscribeIdTextModule) render: -> @@ -422,6 +416,19 @@ class Edit extends App.Controller # enable user popups @userPopups() + # show text module UI + if !@isRole('Customer') + textModule = new App.WidgetTextModule( + el: @el.find('textarea') + data: + ticket: ticket + ) + callback = (ticket) => + textModule.reload( + ticket: ticket + ) + @subscribeIdTextModule = ticket.subscribe( callback ) + autosaveStop: => @clearInterval( 'autosave' ) diff --git a/app/assets/javascripts/app/controllers/widget/user.js.coffee b/app/assets/javascripts/app/controllers/widget/user.js.coffee index 7ffe95c1d..ac8b48d0d 100644 --- a/app/assets/javascripts/app/controllers/widget/user.js.coffee +++ b/app/assets/javascripts/app/controllers/widget/user.js.coffee @@ -14,6 +14,10 @@ class App.WidgetUser extends App.ControllerDrox render: (user) => + # execute callback on render/rerender + if @callback + @callback(user) + # get display data userData = [] for item2 in App.User.configure_attributes diff --git a/test/browser/text_module_test.rb b/test/browser/text_module_test.rb index edfeb348c..0c326c6ec 100644 --- a/test/browser/text_module_test.rb +++ b/test/browser/text_module_test.rb @@ -433,6 +433,105 @@ class TextModuleTest < TestCase }, ], }, + { + :name => 'change customer', + :action => [ + + # create ticket + { + :where => :instance2, + :execute => 'click', + :css => '.active .action button', + }, + { + :execute => 'wait', + :value => 1, + }, + { + :where => :instance2, + :execute => 'click', + :css => '.active .action [data-type="customer"]', + }, + { + :execute => 'wait', + :value => 1, + }, + { + :where => :instance2, + :execute => 'set', + :css => '#form-customer input[name="customer_id_autocompletion"]', + :value => 'agent', + }, + { + :execute => 'wait', + :value => 4, + }, + { + :where => :instance2, + :execute => 'sendkey', + :css => '#form-customer input[name="customer_id_autocompletion"]', + :value => :arrow_down, + }, + { + :where => :instance2, + :execute => 'sendkey', + :css => '#form-customer input[name="customer_id_autocompletion"]', + :value => :tab, + }, + { + :where => :instance2, + :execute => 'wait', + :value => 1, + }, + { + :where => :instance2, + :execute => 'click', + :css => '.modal-content [type="submit"]', + }, + { + :where => :instance2, + :execute => 'wait', + :value => 4, + }, + { + :where => :instance2, + :execute => 'set', + :css => '.active textarea[name=body]', + :value => '::' + random, + }, + { + :execute => 'wait', + :value => 1, + }, + { + :where => :instance2, + :execute => 'match', + :css => 'body', + :value => random, + :match_result => true, + }, + { + :where => :instance2, + :execute => 'click', + :css => '.-sew-list-item.selected', + }, + { + :execute => 'wait', + :value => 1, + }, + { + :where => :instance2, + :execute => 'match', + :css => '.active textarea[name=body]', + :value => 'some content .+?Manag.+?' + random, + :no_quote => true, + :match_result => true, + }, + + ], + }, + + ] browser_double_test(tests) end