From 442da38eae932e2994ed4eb30cc0e22e2e577ed1 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 20 Nov 2015 12:06:50 +0100 Subject: [PATCH 1/2] Fixed all users in ticket owner selection in zoom and bulk. --- .../controllers/agent_ticket_create.coffee | 2 +- .../app/controllers/ticket_overview.coffee | 25 +++++++++++++------ app/controllers/tickets_controller.rb | 11 +++----- app/models/ticket/screen_options.rb | 4 +-- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.coffee index 5a6dfe37a..746ea52ef 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.coffee @@ -238,7 +238,7 @@ class App.TicketCreate extends App.Controller @ticketFormChanges, signatureChanges, ] - filter: @formMeta.filter + filter: @formMeta.filter autofocus: true params: params ) diff --git a/app/assets/javascripts/app/controllers/ticket_overview.coffee b/app/assets/javascripts/app/controllers/ticket_overview.coffee index 0444575e2..e77a38a5b 100644 --- a/app/assets/javascripts/app/controllers/ticket_overview.coffee +++ b/app/assets/javascripts/app/controllers/ticket_overview.coffee @@ -458,16 +458,23 @@ class BulkForm extends App.Controller super @configure_attributes_ticket = [ - { name: 'state_id', display: 'State', tag: 'select', multiple: false, null: true, relation: 'TicketState', filter: @bulk, translate: true, nulloption: true, default: '', class: '', item_class: '' }, - { name: 'priority_id', display: 'Priority', tag: 'select', multiple: false, null: true, relation: 'TicketPriority', filter: @bulk, translate: true, nulloption: true, default: '', class: '', item_class: '' }, - { name: 'group_id', display: 'Group', tag: 'select', multiple: false, null: true, relation: 'Group', filter: @bulk, nulloption: true, class: '', item_class: '' }, - { name: 'owner_id', display: 'Owner', tag: 'select', multiple: false, null: true, relation: 'User', filter: @bulk, nulloption: true, class: '', item_class: '' } + { name: 'state_id', display: 'State', tag: 'select', multiple: false, null: true, relation: 'TicketState', translate: true, nulloption: true, default: '' }, + { name: 'priority_id', display: 'Priority', tag: 'select', multiple: false, null: true, relation: 'TicketPriority', translate: true, nulloption: true, default: '' }, + { name: 'group_id', display: 'Group', tag: 'select', multiple: false, null: true, relation: 'Group', nulloption: true }, + { name: 'owner_id', display: 'Owner', tag: 'select', multiple: false, null: true, relation: 'User', nulloption: true } ] @holder = @options.holder @visible = false - @render() + load = (data) => + App.Collection.loadAssets(data.assets) + @formMeta = data.form_meta + @render() + @bindId = App.TicketCreateCollection.bind(load) + + release: => + App.TicketCreateCollection.unbind(@bindId) render: -> @el.css 'right', App.Utils.getScrollBarWidth() @@ -480,7 +487,11 @@ class BulkForm extends App.Controller configure_attributes: @configure_attributes_ticket className: 'create' labelClass: 'input-group-addon' - form_data: @bulk + handlers: [ + @ticketFormChanges + ] + params: {} + filter: @formMeta.filter noFieldset: true ) @@ -490,7 +501,6 @@ class BulkForm extends App.Controller configure_attributes: [{ name: 'body', display: 'Comment', tag: 'textarea', rows: 4, null: true, upload: false, item_class: 'flex' }] className: 'create' labelClass: 'input-group-addon' - form_data: @bulk noFieldset: true ) @@ -505,7 +515,6 @@ class BulkForm extends App.Controller configure_attributes: @confirm_attributes className: 'create' labelClass: 'input-group-addon' - form_data: @bulk noFieldset: true ) diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb index ae819aa2d..1cf61bb72 100644 --- a/app/controllers/tickets_controller.rb +++ b/app/controllers/tickets_controller.rb @@ -222,17 +222,17 @@ class TicketsController < ApplicationController # permission check ticket = Ticket.find( params[:id] ) - return if !ticket_permission( ticket ) + return if !ticket_permission(ticket) # get attributes to update - attributes_to_change = Ticket::ScreenOptions.attributes_to_change( user: current_user, ticket: ticket ) + attributes_to_change = Ticket::ScreenOptions.attributes_to_change(user: current_user, ticket: ticket) # get related users assets = attributes_to_change[:assets] assets = ticket.assets(assets) # get related articles - articles = Ticket::Article.where( ticket_id: params[:id] ) + articles = Ticket::Article.where(ticket_id: params[:id]) # get related users article_ids = [] @@ -275,10 +275,7 @@ class TicketsController < ApplicationController assets: assets, links: link_list, tags: tags, - form_meta: { - filter: attributes_to_change[:filter], - dependencies: attributes_to_change[:dependencies], - } + form_meta: attributes_to_change[:form_meta], } end diff --git a/app/models/ticket/screen_options.rb b/app/models/ticket/screen_options.rb index 68ec807c3..e407c4913 100644 --- a/app/models/ticket/screen_options.rb +++ b/app/models/ticket/screen_options.rb @@ -47,9 +47,7 @@ returns end state_types.each {|type| state_type = Ticket::StateType.find_by(name: type) - next if !state_type - state_type.states.each {|state| assets = state.assets(assets) state_ids.push state.id @@ -87,7 +85,7 @@ returns } dependencies = { group_id: { '' => { owner_id: [] } } } - Group.where( active: true ).each { |group| + Group.where(active: true).each { |group| assets = group.assets(assets) dependencies[:group_id][group.id] = { owner_id: [] } group.users.each {|user| From cbca4fa849416a533a6b94c93b6ddd4250940907 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 20 Nov 2015 15:10:50 +0100 Subject: [PATCH 2/2] Removed not needed render events. --- .../app/controllers/taskbar_widget.coffee | 8 ++- .../app/lib/app_post/task_manager.coffee | 71 +++++++++---------- test/browser_test_helper.rb | 7 +- 3 files changed, 41 insertions(+), 45 deletions(-) diff --git a/app/assets/javascripts/app/controllers/taskbar_widget.coffee b/app/assets/javascripts/app/controllers/taskbar_widget.coffee index 04f4dc15b..4f5cc7380 100644 --- a/app/assets/javascripts/app/controllers/taskbar_widget.coffee +++ b/app/assets/javascripts/app/controllers/taskbar_widget.coffee @@ -81,7 +81,7 @@ class App.TaskbarWidget extends App.Controller throw 'No such key attributes found for task item' # check if input has changed - worker = App.TaskManager.worker( key ) + worker = App.TaskManager.worker(key) if !force && worker && worker.changed if worker.changed() new Remove( @@ -91,7 +91,7 @@ class App.TaskbarWidget extends App.Controller return # check if active task is closed - currentTask = App.TaskManager.get( key ) + currentTask = App.TaskManager.get(key) tasks = App.TaskManager.all() active_is_closed = false for task in tasks @@ -99,7 +99,9 @@ class App.TaskbarWidget extends App.Controller active_is_closed = true # 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 return if !active_is_closed diff --git a/app/assets/javascripts/app/lib/app_post/task_manager.coffee b/app/assets/javascripts/app/lib/app_post/task_manager.coffee index 757077590..009805abc 100644 --- a/app/assets/javascripts/app/lib/app_post/task_manager.coffee +++ b/app/assets/javascripts/app/lib/app_post/task_manager.coffee @@ -24,10 +24,10 @@ class App.TaskManager _instance ?= new _taskManagerSingleton _instance.update( key, params ) - @remove: ( key ) -> + @remove: (key, rerender = true) -> if _instance == undefined _instance ?= new _taskManagerSingleton - _instance.remove( key ) + _instance.remove(key, rerender) @notify: ( key ) -> if _instance == undefined @@ -77,23 +77,19 @@ class _taskManagerSingleton extends Spine.Module @tasksInitial() # render on login - App.Event.bind( - 'auth:login' - => - @tasksInitial() + App.Event.bind('auth:login', => + @tasksInitial() 'task' ) # render on logout - App.Event.bind( - 'auth:logout' - => - @reset() + App.Event.bind('auth:logout', => + @reset() 'task' ) # 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: -> @workers = {} @@ -123,11 +119,11 @@ class _taskManagerSingleton extends Spine.Module domID: (key) -> "content_permanent_#{key}" - worker: ( key ) -> + worker: (key) -> return @workers[ key ] if @workers[ key ] return - execute: ( params ) -> + execute: (params) -> # input validation params.key = App.Utils.htmlAttributeCleanup(params.key) @@ -159,7 +155,7 @@ class _taskManagerSingleton extends Spine.Module @activeTaskHistory.push _.clone(params) # 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 @@ -220,7 +216,8 @@ class _taskManagerSingleton extends Spine.Module # start worker for task if not exists @startController(params) - App.Event.trigger 'task:render' + if !params.init + App.Event.trigger 'task:render' startController: (params) => @@ -238,7 +235,7 @@ class _taskManagerSingleton extends Spine.Module @workersStarted[params.key] = true # 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 !params.show @@ -246,9 +243,9 @@ class _taskManagerSingleton extends Spine.Module # hide all other controller / show current controller else - @showControllerHideOthers( params.key, params_app ) + @showControllerHideOthers(params.key, params_app) - showControllerHideOthers: ( thisKey, params_app ) => + showControllerHideOthers: (thisKey, params_app) => for key of @workersStarted if key is thisKey @show(key, params_app) @@ -269,7 +266,6 @@ class _taskManagerSingleton extends Spine.Module # execute controllers show if controller.show controller.show(params_app) - App.Event.trigger('ui:rerender:task') true @@ -291,27 +287,27 @@ class _taskManagerSingleton extends Spine.Module true # get task - get: ( key ) => + get: (key) => for task in @allTasks if task.key is key return task # update task - update: ( key, params ) => - task = @get( key ) + update: (key, params) => + task = @get(key) if !task throw "No such task with '#{key}' to update" for item, value of params task[item] = value - @taskUpdate( task ) + @taskUpdate(task) # remove task certain task from tasks - remove: ( key ) => + remove: (key, rerender) => # remember started task delete @tasksStarted[key] - task = @get( key ) + task = @get(key) return if !task # update @allTasks @@ -327,44 +323,45 @@ class _taskManagerSingleton extends Spine.Module @release(key) # rerender taskbar - App.Event.trigger 'task:render' + if rerender + App.Event.trigger 'task:render' # destroy in backend storage @taskDestroy(task) # set notify of task - notify: ( key ) => - task = @get( key ) + notify: (key) => + task = @get(key) if !task throw "No such task with '#{key}' to notify" task.notify = true - @taskUpdate( task ) + @taskUpdate(task) # unset notify of task - mute: ( key ) => - task = @get( key ) + mute: (key) => + task = @get(key) if !task throw "No such task with '#{key}' to mute" task.notify = false - @taskUpdate( task ) + @taskUpdate(task) # set new order of tasks (needed for dnd) - reorder: ( order ) => + reorder: (order) => prio = 0 for key in order - task = @get( key ) + task = @get(key) if !task throw "No such task with '#{key}' of order" prio++ if task.prio isnt prio task.prio = prio - @taskUpdate( task ) + @taskUpdate(task) # release one task release: (key) => try - @el.find( "##{@domID(key)}" ).html('') - @el.find( "##{@domID(key)}" ).remove() + @el.find("##{@domID(key)}").html('') + @el.find("##{@domID(key)}").remove() catch @log 'notice', "invalid key '#{key}'" diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 7ae563836..84cfc5d31 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -964,8 +964,8 @@ wait untill text in selector disabppears =begin tasks_close_all( - :browser => browser1, - :discard_changes => true, + browser: browser1, + discard_changes: true, ) =end @@ -980,11 +980,8 @@ wait untill text in selector disabppears begin 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] ) - sleep 0.2 - click_element = instance.find_elements( { css: '.navigation .tasks .task:first-child .js-close' } )[0] if click_element - sleep 0.1 click_element.click # accept task close warning