From d54b7bbfc81717ceb288791c0513e259e6f79f43 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sat, 1 Nov 2014 14:04:22 +0100 Subject: [PATCH] Introduced @show and @hide to controller which are executed on show/hide of controller. --- .../controllers/agent_ticket_create.js.coffee | 2 +- .../controllers/organization_zoom.js.coffee | 2 +- .../app/controllers/ticket_zoom.js.coffee | 19 ++++++---------- .../app/controllers/user_zoom.js.coffee | 2 +- .../app/lib/app_post/task_manager.js.coffee | 22 +++++++++++++------ 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee index 0416cf0a1..8c1fd5427 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee @@ -104,7 +104,7 @@ class App.TicketCreate extends App.Controller url: => '#ticket/create/id/' + @id - activate: => + show: => @navupdate '#' changed: => diff --git a/app/assets/javascripts/app/controllers/organization_zoom.js.coffee b/app/assets/javascripts/app/controllers/organization_zoom.js.coffee index 4775baaa3..1b3a4567b 100644 --- a/app/assets/javascripts/app/controllers/organization_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/organization_zoom.js.coffee @@ -31,7 +31,7 @@ class App.OrganizationZoom extends App.Controller url: => '#organization/zoom/' + @organization_id - activate: => + show: => App.OnlineNotification.seen( 'Organization', @organization_id ) @navupdate '#' diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee index 7c5475530..a961363eb 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee @@ -40,9 +40,6 @@ class App.TicketZoom extends App.Controller @delay( update, 1800, 'ticket-zoom-' + @ticket_id ) ) - @bind "task:hide", @onHide - @bind "task:show", @onShow - meta: => meta = url: @url() @@ -58,9 +55,15 @@ class App.TicketZoom extends App.Controller url: => '#ticket/zoom/' + @ticket_id - activate: => + show: => App.OnlineNotification.seen( 'Ticket', @ticket_id ) @navupdate '#' + if @scrollHeader + @scrollHeader.continue() + + hide: => + if @scrollHeader + @scrollHeader.pause() changed: => formCurrent = @formParam( @el.find('.edit') ) @@ -407,14 +410,6 @@ class App.TicketZoom extends App.Controller forceHeight: false holder: @main.get(0) - onShow: => - if @scrollHeader - @scrollHeader.continue() - - onHide: => - if @scrollHeader - @scrollHeader.pause() - autosaveStop: => @autosaveLast = {} @clearInterval( 'autosave' ) diff --git a/app/assets/javascripts/app/controllers/user_zoom.js.coffee b/app/assets/javascripts/app/controllers/user_zoom.js.coffee index cffdbc1fd..bdfb836ef 100644 --- a/app/assets/javascripts/app/controllers/user_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/user_zoom.js.coffee @@ -30,7 +30,7 @@ class App.UserZoom extends App.Controller url: => '#user/zoom/' + @user_id - activate: => + show: => App.OnlineNotification.seen( 'User', @user_id ) @navupdate '#' diff --git a/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee b/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee index e041537a0..e31f1c11f 100644 --- a/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee @@ -206,12 +206,8 @@ class _taskManagerSingleton extends App.Controller # return if controller is already started if @workersStarted[key] - - # activate existing controller - worker = @worker( key ) - if worker && worker.activate && !to_not_show - worker.activate(params_app) - App.Event.trigger('ui:rerender:task') + if !to_not_show + @showController( key, params_app ) return @workersStarted[key] = true @@ -222,10 +218,22 @@ class _taskManagerSingleton extends App.Controller # activate controller if !to_not_show - a.activate(params_app) + @showController( key, params_app ) return a + showController: ( thisKey, params_app ) => + for key of @workersStarted + controller = @workers[ key ] + if controller + if key is thisKey + if controller.show + controller.show(params_app) + App.Event.trigger('ui:rerender:task') + else + if controller.hide + controller.hide() + get: ( key ) => for task in @allTasks if task.key is key