Fixed issue #2209 - Order of relation select fields (Group, State etc.) values is broken.
This commit is contained in:
parent
2c86e2cae1
commit
1bc9f245e6
2 changed files with 42 additions and 3 deletions
|
@ -38,6 +38,7 @@ class App.UiElement.select extends App.UiElement.ApplicationUiElement
|
||||||
# 1. If attribute.value is not among the current options, then search within historical options
|
# 1. If attribute.value is not among the current options, then search within historical options
|
||||||
# 2. If attribute.value is not among current and historical options, then add the value itself as an option
|
# 2. If attribute.value is not among current and historical options, then add the value itself as an option
|
||||||
@addDeletedOptions: (attribute) ->
|
@addDeletedOptions: (attribute) ->
|
||||||
|
return if !_.isEmpty(attribute.relation) # do not apply for attributes with relation, relations will fill options automatically
|
||||||
value = attribute.value
|
value = attribute.value
|
||||||
return if !value
|
return if !value
|
||||||
return if _.isArray(value)
|
return if _.isArray(value)
|
||||||
|
|
|
@ -93,6 +93,8 @@ test('form checks', function() {
|
||||||
priority1_id: '1',
|
priority1_id: '1',
|
||||||
priority2_id: ['1', '2'],
|
priority2_id: ['1', '2'],
|
||||||
priority3_id: '2',
|
priority3_id: '2',
|
||||||
|
priority4_id: '2',
|
||||||
|
priority5_id: '1',
|
||||||
working_hours: {
|
working_hours: {
|
||||||
mon: {
|
mon: {
|
||||||
active: true,
|
active: true,
|
||||||
|
@ -146,9 +148,11 @@ test('form checks', function() {
|
||||||
el: el,
|
el: el,
|
||||||
model: {
|
model: {
|
||||||
configure_attributes: [
|
configure_attributes: [
|
||||||
{ name: 'priority1_id', display: 'Priroity1', tag: 'select', relation: 'TicketPriority', null: true, options: {} },
|
{ name: 'priority1_id', display: 'Priroity1 (with active selection)', tag: 'select', relation: 'TicketPriority', null: true, options: {} },
|
||||||
{ name: 'priority2_id', display: 'Priroity2', tag: 'select', multiple: true, relation: 'TicketPriority', null: true, options: {} },
|
{ name: 'priority2_id', display: 'Priroity2 (with active and inactive selection)', tag: 'select', multiple: true, relation: 'TicketPriority', null: true, options: {} },
|
||||||
{ name: 'priority3_id', display: 'Priroity3', tag: 'select', relation: 'TicketPriority', null: true },
|
{ name: 'priority3_id', display: 'Priroity3 (with inactive selection)', tag: 'select', relation: 'TicketPriority', null: true, options: {} },
|
||||||
|
{ name: 'priority4_id', display: 'Priroity4 (with inactive selection)', tag: 'select', multiple: true, relation: 'TicketPriority', null: true, options: {} },
|
||||||
|
{ name: 'priority5_id', display: 'Priroity5 (with active selection)', tag: 'select', multiple: true, relation: 'TicketPriority', null: true, options: {} },
|
||||||
{ name: 'escalation_times', display: 'Times', tag: 'sla_times', null: true },
|
{ name: 'escalation_times', display: 'Times', tag: 'sla_times', null: true },
|
||||||
{ name: 'working_hours', display: 'Hours', tag: 'business_hours', null: true },
|
{ name: 'working_hours', display: 'Hours', tag: 'business_hours', null: true },
|
||||||
]
|
]
|
||||||
|
@ -161,6 +165,8 @@ test('form checks', function() {
|
||||||
priority1_id: '1',
|
priority1_id: '1',
|
||||||
priority2_id: ['1', '2'],
|
priority2_id: ['1', '2'],
|
||||||
priority3_id: '2',
|
priority3_id: '2',
|
||||||
|
priority4_id: '2',
|
||||||
|
priority5_id: '1',
|
||||||
first_response_time: '150',
|
first_response_time: '150',
|
||||||
first_response_time_in_text: '02:30',
|
first_response_time_in_text: '02:30',
|
||||||
solution_time: '',
|
solution_time: '',
|
||||||
|
@ -219,6 +225,36 @@ test('form checks', function() {
|
||||||
equal(el.find('[name="priority1_id"] option').length, 3)
|
equal(el.find('[name="priority1_id"] option').length, 3)
|
||||||
equal(el.find('[name="priority2_id"] option').length, 4)
|
equal(el.find('[name="priority2_id"] option').length, 4)
|
||||||
equal(el.find('[name="priority3_id"] option').length, 4)
|
equal(el.find('[name="priority3_id"] option').length, 4)
|
||||||
|
equal(el.find('[name="priority4_id"] option').length, 4)
|
||||||
|
equal(el.find('[name="priority5_id"] option').length, 3)
|
||||||
|
|
||||||
|
// check priority1_id selection order
|
||||||
|
equal(el.find('[name="priority1_id"] option:nth-child(1)').text(), '1 low')
|
||||||
|
equal(el.find('[name="priority1_id"] option:nth-child(2)').text(), '3 high')
|
||||||
|
equal(el.find('[name="priority1_id"] option:nth-child(3)').text(), '4 very high')
|
||||||
|
|
||||||
|
// check priority2_id selection order
|
||||||
|
equal(el.find('[name="priority2_id"] option:nth-child(1)').text(), '1 low')
|
||||||
|
equal(el.find('[name="priority2_id"] option:nth-child(2)').text(), '2 normal')
|
||||||
|
equal(el.find('[name="priority2_id"] option:nth-child(3)').text(), '3 high')
|
||||||
|
equal(el.find('[name="priority2_id"] option:nth-child(4)').text(), '4 very high')
|
||||||
|
|
||||||
|
// check priority3_id selection order
|
||||||
|
equal(el.find('[name="priority3_id"] option:nth-child(1)').text(), '1 low')
|
||||||
|
equal(el.find('[name="priority3_id"] option:nth-child(2)').text(), '2 normal')
|
||||||
|
equal(el.find('[name="priority3_id"] option:nth-child(3)').text(), '3 high')
|
||||||
|
equal(el.find('[name="priority3_id"] option:nth-child(4)').text(), '4 very high')
|
||||||
|
|
||||||
|
// check priority4_id selection order
|
||||||
|
equal(el.find('[name="priority4_id"] option:nth-child(1)').text(), '1 low')
|
||||||
|
equal(el.find('[name="priority4_id"] option:nth-child(2)').text(), '2 normal')
|
||||||
|
equal(el.find('[name="priority4_id"] option:nth-child(3)').text(), '3 high')
|
||||||
|
equal(el.find('[name="priority4_id"] option:nth-child(4)').text(), '4 very high')
|
||||||
|
|
||||||
|
// check priority5_id selection order
|
||||||
|
equal(el.find('[name="priority5_id"] option:nth-child(1)').text(), '1 low')
|
||||||
|
equal(el.find('[name="priority5_id"] option:nth-child(2)').text(), '3 high')
|
||||||
|
equal(el.find('[name="priority5_id"] option:nth-child(3)').text(), '4 very high')
|
||||||
|
|
||||||
// change sla times
|
// change sla times
|
||||||
el.find('[name="first_response_time_in_text"]').val('0:30').trigger('blur')
|
el.find('[name="first_response_time_in_text"]').val('0:30').trigger('blur')
|
||||||
|
@ -229,6 +265,8 @@ test('form checks', function() {
|
||||||
priority1_id: '1',
|
priority1_id: '1',
|
||||||
priority2_id: ['1', '2'],
|
priority2_id: ['1', '2'],
|
||||||
priority3_id: '2',
|
priority3_id: '2',
|
||||||
|
priority4_id: '2',
|
||||||
|
priority5_id: '1',
|
||||||
working_hours: {
|
working_hours: {
|
||||||
mon: {
|
mon: {
|
||||||
active: true,
|
active: true,
|
||||||
|
|
Loading…
Reference in a new issue