Improved UI for ignore certains agents to not use auto assignment - follow up for issue #1825.

This commit is contained in:
Martin Edenhofer 2018-06-04 14:57:53 +02:00
parent 312278c2d6
commit fd120eda96
6 changed files with 145 additions and 10 deletions

View file

@ -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')

View file

@ -8,12 +8,13 @@
</div>
</div>
<div class="page-content">
<div class="settings-entry">
<form class="settings-entry">
<p><%- @T('Enable automatic assignment the first time an agent opens a ticket.') %></p>
<p><%- @T('Tickets are only assigned automatically if they do not already have an owner.') %></p>
<div class="js-selector"></div>
<p><%- @T('Define an exception of "automatic assignment" for certain users (e.g. executives).') %></p>
<div class="js-users"></div>
<button type="submit" class="btn btn--primary js-timeAccountingFilter"><%- @T('Save') %></button>
<button type="submit" class="btn btn--danger js-timeAccountingFilterReset"><%- @T('Reset') %></button>
</div>
<div class="settings-entry">
</form>
</div>

View file

@ -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

View file

@ -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',

View file

@ -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

View file

@ -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