Removed not needed render events.

This commit is contained in:
Martin Edenhofer 2015-11-20 15:10:50 +01:00
parent 7315e87b08
commit cbca4fa849
3 changed files with 41 additions and 45 deletions

View file

@ -81,7 +81,7 @@ class App.TaskbarWidget extends App.Controller
throw 'No such key attributes found for task item' throw 'No such key attributes found for task item'
# check if input has changed # check if input has changed
worker = App.TaskManager.worker( key ) worker = App.TaskManager.worker(key)
if !force && worker && worker.changed if !force && worker && worker.changed
if worker.changed() if worker.changed()
new Remove( new Remove(
@ -91,7 +91,7 @@ class App.TaskbarWidget extends App.Controller
return return
# check if active task is closed # check if active task is closed
currentTask = App.TaskManager.get( key ) currentTask = App.TaskManager.get(key)
tasks = App.TaskManager.all() tasks = App.TaskManager.all()
active_is_closed = false active_is_closed = false
for task in tasks for task in tasks
@ -99,7 +99,9 @@ class App.TaskbarWidget extends App.Controller
active_is_closed = true active_is_closed = true
# remove task # remove task
App.TaskManager.remove( key ) App.TaskManager.remove(key, false)
$(e.target).closest('.task').remove()
# if we do not need to move to an other task # if we do not need to move to an other task
return if !active_is_closed return if !active_is_closed

View file

@ -24,10 +24,10 @@ class App.TaskManager
_instance ?= new _taskManagerSingleton _instance ?= new _taskManagerSingleton
_instance.update( key, params ) _instance.update( key, params )
@remove: ( key ) -> @remove: (key, rerender = true) ->
if _instance == undefined if _instance == undefined
_instance ?= new _taskManagerSingleton _instance ?= new _taskManagerSingleton
_instance.remove( key ) _instance.remove(key, rerender)
@notify: ( key ) -> @notify: ( key ) ->
if _instance == undefined if _instance == undefined
@ -77,23 +77,19 @@ class _taskManagerSingleton extends Spine.Module
@tasksInitial() @tasksInitial()
# render on login # render on login
App.Event.bind( App.Event.bind('auth:login', =>
'auth:login' @tasksInitial()
=>
@tasksInitial()
'task' 'task'
) )
# render on logout # render on logout
App.Event.bind( App.Event.bind('auth:logout', =>
'auth:logout' @reset()
=>
@reset()
'task' 'task'
) )
# send updates to server # send updates to server
App.Interval.set( @taskUpdateLoop, 2500, 'check_update_to_server_pending', 'task' ) App.Interval.set(@taskUpdateLoop, 2500, 'check_update_to_server_pending', 'task')
init: -> init: ->
@workers = {} @workers = {}
@ -123,11 +119,11 @@ class _taskManagerSingleton extends Spine.Module
domID: (key) -> domID: (key) ->
"content_permanent_#{key}" "content_permanent_#{key}"
worker: ( key ) -> worker: (key) ->
return @workers[ key ] if @workers[ key ] return @workers[ key ] if @workers[ key ]
return return
execute: ( params ) -> execute: (params) ->
# input validation # input validation
params.key = App.Utils.htmlAttributeCleanup(params.key) params.key = App.Utils.htmlAttributeCleanup(params.key)
@ -159,7 +155,7 @@ class _taskManagerSingleton extends Spine.Module
@activeTaskHistory.push _.clone(params) @activeTaskHistory.push _.clone(params)
# check if task already exists in storage / e. g. from last session # check if task already exists in storage / e. g. from last session
task = @get( params.key ) task = @get(params.key)
#console.log 'debug', 'execute', params, 'task', task #console.log 'debug', 'execute', params, 'task', task
@ -220,7 +216,8 @@ class _taskManagerSingleton extends Spine.Module
# start worker for task if not exists # start worker for task if not exists
@startController(params) @startController(params)
App.Event.trigger 'task:render' if !params.init
App.Event.trigger 'task:render'
startController: (params) => startController: (params) =>
@ -238,7 +235,7 @@ class _taskManagerSingleton extends Spine.Module
@workersStarted[params.key] = true @workersStarted[params.key] = true
# create new controller instanz # create new controller instanz
@workers[params.key] = new App[params.controller]( params_app ) @workers[params.key] = new App[params.controller](params_app)
# if controller is started hidden, call hide of controller # if controller is started hidden, call hide of controller
if !params.show if !params.show
@ -246,9 +243,9 @@ class _taskManagerSingleton extends Spine.Module
# hide all other controller / show current controller # hide all other controller / show current controller
else else
@showControllerHideOthers( params.key, params_app ) @showControllerHideOthers(params.key, params_app)
showControllerHideOthers: ( thisKey, params_app ) => showControllerHideOthers: (thisKey, params_app) =>
for key of @workersStarted for key of @workersStarted
if key is thisKey if key is thisKey
@show(key, params_app) @show(key, params_app)
@ -269,7 +266,6 @@ class _taskManagerSingleton extends Spine.Module
# execute controllers show # execute controllers show
if controller.show if controller.show
controller.show(params_app) controller.show(params_app)
App.Event.trigger('ui:rerender:task')
true true
@ -291,27 +287,27 @@ class _taskManagerSingleton extends Spine.Module
true true
# get task # get task
get: ( key ) => get: (key) =>
for task in @allTasks for task in @allTasks
if task.key is key if task.key is key
return task return task
# update task # update task
update: ( key, params ) => update: (key, params) =>
task = @get( key ) task = @get(key)
if !task if !task
throw "No such task with '#{key}' to update" throw "No such task with '#{key}' to update"
for item, value of params for item, value of params
task[item] = value task[item] = value
@taskUpdate( task ) @taskUpdate(task)
# remove task certain task from tasks # remove task certain task from tasks
remove: ( key ) => remove: (key, rerender) =>
# remember started task # remember started task
delete @tasksStarted[key] delete @tasksStarted[key]
task = @get( key ) task = @get(key)
return if !task return if !task
# update @allTasks # update @allTasks
@ -327,44 +323,45 @@ class _taskManagerSingleton extends Spine.Module
@release(key) @release(key)
# rerender taskbar # rerender taskbar
App.Event.trigger 'task:render' if rerender
App.Event.trigger 'task:render'
# destroy in backend storage # destroy in backend storage
@taskDestroy(task) @taskDestroy(task)
# set notify of task # set notify of task
notify: ( key ) => notify: (key) =>
task = @get( key ) task = @get(key)
if !task if !task
throw "No such task with '#{key}' to notify" throw "No such task with '#{key}' to notify"
task.notify = true task.notify = true
@taskUpdate( task ) @taskUpdate(task)
# unset notify of task # unset notify of task
mute: ( key ) => mute: (key) =>
task = @get( key ) task = @get(key)
if !task if !task
throw "No such task with '#{key}' to mute" throw "No such task with '#{key}' to mute"
task.notify = false task.notify = false
@taskUpdate( task ) @taskUpdate(task)
# set new order of tasks (needed for dnd) # set new order of tasks (needed for dnd)
reorder: ( order ) => reorder: (order) =>
prio = 0 prio = 0
for key in order for key in order
task = @get( key ) task = @get(key)
if !task if !task
throw "No such task with '#{key}' of order" throw "No such task with '#{key}' of order"
prio++ prio++
if task.prio isnt prio if task.prio isnt prio
task.prio = prio task.prio = prio
@taskUpdate( task ) @taskUpdate(task)
# release one task # release one task
release: (key) => release: (key) =>
try try
@el.find( "##{@domID(key)}" ).html('') @el.find("##{@domID(key)}").html('')
@el.find( "##{@domID(key)}" ).remove() @el.find("##{@domID(key)}").remove()
catch catch
@log 'notice', "invalid key '#{key}'" @log 'notice', "invalid key '#{key}'"

View file

@ -964,8 +964,8 @@ wait untill text in selector disabppears
=begin =begin
tasks_close_all( tasks_close_all(
:browser => browser1, browser: browser1,
:discard_changes => true, discard_changes: true,
) )
=end =end
@ -980,11 +980,8 @@ wait untill text in selector disabppears
begin begin
if instance.find_elements( { css: '.navigation .tasks .task:first-child' } )[0] if instance.find_elements( { css: '.navigation .tasks .task:first-child' } )[0]
instance.mouse.move_to( instance.find_elements( { css: '.navigation .tasks .task:first-child' } )[0] ) instance.mouse.move_to( instance.find_elements( { css: '.navigation .tasks .task:first-child' } )[0] )
sleep 0.2
click_element = instance.find_elements( { css: '.navigation .tasks .task:first-child .js-close' } )[0] click_element = instance.find_elements( { css: '.navigation .tasks .task:first-child .js-close' } )[0]
if click_element if click_element
sleep 0.1
click_element.click click_element.click
# accept task close warning # accept task close warning