Fixes #2852 - Default Priority on ticket creation not changeable
This commit is contained in:
parent
d0e5614689
commit
9973839e44
4 changed files with 50 additions and 8 deletions
|
@ -33,6 +33,7 @@ class App.TicketCreate extends App.Controller
|
|||
# define default type and available types
|
||||
@defaultType = @Config.get('ui_ticket_create_default_type')
|
||||
@availableTypes = @Config.get('ui_ticket_create_available_types') || []
|
||||
|
||||
if !_.isArray(@availableTypes)
|
||||
@availableTypes = [@availableTypes]
|
||||
|
||||
|
@ -295,6 +296,8 @@ class App.TicketCreate extends App.Controller
|
|||
if !_.isEmpty(params['form_id'])
|
||||
@formId = params['form_id']
|
||||
|
||||
params.priority_id ||= App.TicketPriority.findByAttribute( 'default_create', true )?.id
|
||||
|
||||
@html(App.view('agent_ticket_create')(
|
||||
head: 'New Ticket'
|
||||
agent: @permissionCheck('ticket.agent')
|
||||
|
|
|
@ -119,11 +119,6 @@ class CustomerTicketCreate extends App.ControllerAppContent
|
|||
# set customer id
|
||||
params.customer_id = @Session.get('id')
|
||||
|
||||
# set prio
|
||||
if !params.priority_id
|
||||
priority = App.TicketPriority.findByAttribute( 'default_create', true )
|
||||
params.priority_id = priority.id
|
||||
|
||||
# set state
|
||||
if !params.state_id
|
||||
state = App.TicketState.findByAttribute( 'default_create', true )
|
||||
|
|
|
@ -11,7 +11,7 @@ class App.Ticket extends App.Model
|
|||
{ name: 'owner_id', display: 'Owner', tag: 'select', multiple: false, limit: 100, null: true, relation: 'User', width: '12%', edit: true },
|
||||
{ name: 'state_id', display: 'State', tag: 'select', multiple: false, null: false, relation: 'TicketState', default: 'new', width: '12%', edit: true, customer: true },
|
||||
{ name: 'pending_time', display: 'Pending till', tag: 'datetime', null: true, width: '130px' },
|
||||
{ name: 'priority_id', display: 'Priority', tag: 'select', multiple: false, null: false, relation: 'TicketPriority', default: '2 normal', width: '54px', edit: true, customer: true },
|
||||
{ name: 'priority_id', display: 'Priority', tag: 'select', multiple: false, null: false, relation: 'TicketPriority', width: '54px', edit: true, customer: true },
|
||||
{ name: 'article_count', display: 'Article#', readonly: 1, width: '12%' },
|
||||
{ name: 'time_unit', display: 'Accounted Time', readonly: 1, width: '12%' },
|
||||
{ name: 'escalation_at', display: 'Escalation at', tag: 'datetime', null: true, readonly: 1, width: '110px', class: 'escalation' },
|
||||
|
|
|
@ -683,4 +683,48 @@ RSpec.describe 'Ticket Create', type: :system do
|
|||
expect(Ticket.last.pending_time).to be nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'default priority' do
|
||||
let!(:template) { create(:template, :dummy_data) }
|
||||
let!(:ticket_priority) { create(:ticket_priority, default_create: true) }
|
||||
let(:another_priority) { Ticket::Priority.find(1) }
|
||||
let(:priority_field) { find('[name=priority_id]') }
|
||||
|
||||
it 'shows default priority on load' do
|
||||
visit 'ticket/create'
|
||||
|
||||
expect(priority_field.value).to eq ticket_priority.id.to_s
|
||||
end
|
||||
|
||||
it 'does not reset to default priority on reload' do
|
||||
visit 'ticket/create'
|
||||
|
||||
taskbar_timestamp = Taskbar.last.updated_at
|
||||
|
||||
priority_field.select another_priority.name
|
||||
|
||||
wait.until { Taskbar.last.updated_at != taskbar_timestamp }
|
||||
|
||||
refresh
|
||||
|
||||
expect(priority_field.reload.value).to eq another_priority.id.to_s
|
||||
end
|
||||
|
||||
it 'saves default priority' do
|
||||
visit 'ticket/create'
|
||||
use_template template
|
||||
click '.js-submit'
|
||||
|
||||
expect(Ticket.last).to have_attributes(priority: ticket_priority)
|
||||
end
|
||||
|
||||
it 'saves different priority if overriden' do
|
||||
visit 'ticket/create'
|
||||
use_template template
|
||||
priority_field.select another_priority.name
|
||||
click '.js-submit'
|
||||
|
||||
expect(Ticket.last).to have_attributes(priority: another_priority)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue