From 442da38eae932e2994ed4eb30cc0e22e2e577ed1 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 20 Nov 2015 12:06:50 +0100 Subject: [PATCH] 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|