diff --git a/app/assets/javascripts/app/controllers/_manage/ticket_auto_assignment.coffee b/app/assets/javascripts/app/controllers/_manage/ticket_auto_assignment.coffee index cab7231fa..2abef3251 100644 --- a/app/assets/javascripts/app/controllers/_manage/ticket_auto_assignment.coffee +++ b/app/assets/javascripts/app/controllers/_manage/ticket_auto_assignment.coffee @@ -22,18 +22,32 @@ class App.SettingTicketAutoAssignment extends App.ControllerSubContent @html(App.view('settings/ticket_auto_assignment')()) configure_attributes = [ - { name: 'condition', display: 'Conditions for effected objects', tag: 'ticket_selector', null: false, preview: false, action: false, hasChanged: false }, + { name: 'condition', display: 'Conditions for effected objects', tag: 'ticket_selector', null: false, preview: false, action: false, hasChanged: false }, ] - filter_params = App.Setting.get('ticket_auto_assignment_selector') + ticket_auto_assignment_selector = App.Setting.get('ticket_auto_assignment_selector') @filter = new App.ControllerForm( el: @$('.js-selector') model: configure_attributes: configure_attributes, - params: filter_params + params: + condition: ticket_auto_assignment_selector.condition autofocus: true ) + configure_attributes = [ + { name: 'user_ids', display: 'Exception users', tag: 'column_select', multiple: true, null: true, relation: 'User', sortBy: 'firstname' }, + ] + + ticket_auto_assignment_user_ids_ignore = App.Setting.get('ticket_auto_assignment_user_ids_ignore') + @filter = new App.ControllerForm( + el: @$('.js-users') + model: + configure_attributes: configure_attributes, + params: + user_ids: ticket_auto_assignment_user_ids_ignore + autofocus: false + ) setFilter: (e) => e.preventDefault() @@ -41,14 +55,16 @@ class App.SettingTicketAutoAssignment extends App.ControllerSubContent # get form data params = @formParam(@filter.form) - # save filter settings - App.Setting.set('ticket_auto_assignment_selector', params, notify: true) + # save settings + App.Setting.set('ticket_auto_assignment_selector', { condition: params.condition }, notify: true) + App.Setting.set('ticket_auto_assignment_user_ids_ignore', params.user_ids, notify: false) resetFilter: (e) -> e.preventDefault() # save filter settings App.Setting.set('ticket_auto_assignment_selector', {}, notify: true) + App.Setting.set('ticket_auto_assignment_user_ids_ignore', [], notify: false) setTicketAutoAssignment: (e) => value = @ticketAutoAssignment.prop('checked') diff --git a/app/assets/javascripts/app/views/settings/ticket_auto_assignment.jst.eco b/app/assets/javascripts/app/views/settings/ticket_auto_assignment.jst.eco index d698c2087..d3e934b4d 100644 --- a/app/assets/javascripts/app/views/settings/ticket_auto_assignment.jst.eco +++ b/app/assets/javascripts/app/views/settings/ticket_auto_assignment.jst.eco @@ -8,12 +8,13 @@
-
+

<%- @T('Enable automatic assignment the first time an agent opens a ticket.') %>

<%- @T('Tickets are only assigned automatically if they do not already have an owner.') %>

+

<%- @T('Define an exception of "automatic assignment" for certain users (e.g. executives).') %>

+
-
-
+
diff --git a/db/migrate/20180604000001_setting_add_ticket_auto_assignment2.rb b/db/migrate/20180604000001_setting_add_ticket_auto_assignment2.rb new file mode 100644 index 000000000..61cadc108 --- /dev/null +++ b/db/migrate/20180604000001_setting_add_ticket_auto_assignment2.rb @@ -0,0 +1,68 @@ +class SettingAddTicketAutoAssignment2 < ActiveRecord::Migration[5.1] + def up + + # return if it's a new setup + return if !Setting.find_by(name: 'system_init_done') + + Setting.create_if_not_exists( + title: 'Auto Assigment', + name: 'ticket_auto_assignment', + area: 'Web::Base', + description: 'Enable ticket auto assignment.', + options: { + form: [ + { + display: '', + null: true, + name: 'ticket_auto_assignment', + tag: 'boolean', + options: { + true => 'yes', + false => 'no', + }, + }, + ], + }, + preferences: { + authentication: true, + permission: ['admin.ticket_auto_assignment'], + }, + state: false, + frontend: true + ) + Setting.create_if_not_exists( + title: 'Time Accounting Selector', + name: 'ticket_auto_assignment_selector', + area: 'Web::Base', + description: 'Enable auto assignment for following matching tickets.', + options: { + form: [ + {}, + ], + }, + preferences: { + authentication: true, + permission: ['admin.ticket_auto_assignment'], + }, + state: { condition: { 'ticket.state_id' => { operator: 'is', value: Ticket::State.by_category(:work_on).pluck(:id) } } }, + frontend: true + ) + Setting.create_or_update( + title: 'Time Accounting Selector', + name: 'ticket_auto_assignment_user_ids_ignore', + area: 'Web::Base', + description: 'Define an exception of "automatic assignment" for certain users (e.g. executives).', + options: { + form: [ + {}, + ], + }, + preferences: { + authentication: true, + permission: ['admin.ticket_auto_assignment'], + }, + state: [], + frontend: true + ) + end +end diff --git a/db/seeds/settings.rb b/db/seeds/settings.rb index 91708b2ca..93e98bf1e 100644 --- a/db/seeds/settings.rb +++ b/db/seeds/settings.rb @@ -1974,7 +1974,23 @@ Setting.create_if_not_exists( state: { condition: { 'ticket.state_id' => { operator: 'is', value: Ticket::State.by_category(:work_on).pluck(:id) } } }, frontend: true ) - +Setting.create_or_update( + title: 'Time Accounting Selector', + name: 'ticket_auto_assignment_user_ids_ignore', + area: 'Web::Base', + description: 'Define an exception of "automatic assignment" for certain users (e.g. executives).', + options: { + form: [ + {}, + ], + }, + preferences: { + authentication: true, + permission: ['admin.ticket_auto_assignment'], + }, + state: [], + frontend: true +) Setting.create_if_not_exists( title: 'Ticket Number ignore system_id', name: 'ticket_number_ignore_system_id', diff --git a/test/browser/agent_ticket_auto_assignment_test.rb b/test/browser/agent_ticket_auto_assignment_test.rb index b388fc27f..8e3b9c335 100644 --- a/test/browser/agent_ticket_auto_assignment_test.rb +++ b/test/browser/agent_ticket_auto_assignment_test.rb @@ -35,6 +35,15 @@ class AgentTicketAutoAssignmentTest < TestCase }, ) + ticket3 = ticket_create( + data: { + customer: 'nico', + group: 'Users', + title: 'test_auto_assignment_3 - ticket 3', + body: 'test_auto_assignment_3 - ticket 3 - no auto assignment', + }, + ) + tasks_close_all() logout() @@ -103,6 +112,31 @@ class AgentTicketAutoAssignmentTest < TestCase timeout: 2, ) + # define auto assignment exception + click(css: 'a[href="#manage"]') + click(css: '.content.active a[href="#settings/ticket"]') + click(css: '.content.active a[href="#auto_assignment"]') + click(css: '.content.active .js-select.js-option[title="master@example.com"]') + click(css: '.content.active .js-timeAccountingFilter') + + watch_for_disappear( + css: '.content.active .sidebar select[name="owner_id"]', + value: 'Test Master', + timeout: 10, + ) + + # open ticket#3 + ticket_open_by_search( + number: ticket3[:number], + ) + + # verify if owner is not set + sleep 6 + match( + css: '.content.active .sidebar select[name="owner_id"]', + value: '-', + ) + tasks_close_all() # disable auto assignment diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index b55b53f91..c8b5c4515 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -2032,7 +2032,7 @@ wait untill text in selector disabppears number: number, title: data[:title], } - sleep 3 # wait until notify is gone + sleep 2 # wait until notify is gone return ticket end end