From 26b9eb028131fd9ef0400eca9966f834952710e7 Mon Sep 17 00:00:00 2001 From: Romit Choudhary Date: Fri, 2 Jul 2021 07:17:11 +0000 Subject: [PATCH] Fixes #3335 - State list of tickets ignore locale for their sorting --- .../_ui_element/_application_ui_element.coffee | 16 +++++----------- spec/system/ticket/zoom_spec.rb | 6 +++--- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_ui_element/_application_ui_element.coffee b/app/assets/javascripts/app/controllers/_ui_element/_application_ui_element.coffee index 23baba2ed..605f1d052 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/_application_ui_element.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/_application_ui_element.coffee @@ -114,27 +114,21 @@ class App.UiElement.ApplicationUiElement App.Log.debug 'ControllerForm', '_getRelationOptionList:filter-array', attribute.filter + filter = _.clone(attribute.filter) + if !attribute.rejectNonExistentValues && params[ attribute.name ] && !_.contains(filter, params[ attribute.name ]) + filter.push(params[ attribute.name ]) + # check all records for record in App[ attribute.relation ].search(sortBy: attribute.sortBy, translate: attribute.translate) # check all filter attributes - for key in attribute.filter + for key in filter # check all filter values as array # if it's matching, use it for selection if record['id'] is key || ( record['id'] && key && record['id'].toString() is key.toString() ) list.push record - # check if current value need to be added - if params[ attribute.name ] && !attribute.rejectNonExistentValues - hit = false - for value in list - if value['id'].toString() is params[ attribute.name ].toString() - hit = true - if !hit - currentRecord = App[ attribute.relation ].find(params[ attribute.name ]) - list.push currentRecord - # no data filter matched else App.Log.debug 'ControllerForm', '_getRelationOptionList:filter-data no filter matched' diff --git a/spec/system/ticket/zoom_spec.rb b/spec/system/ticket/zoom_spec.rb index 2a0ec49fe..61e776517 100644 --- a/spec/system/ticket/zoom_spec.rb +++ b/spec/system/ticket/zoom_spec.rb @@ -923,11 +923,11 @@ RSpec.describe 'Ticket zoom', type: :system do let(:user) { create(:customer) } let(:ticket) { create(:ticket, customer: user) } - it 'shows ticket state dropdown options in sorted order, with new at the end' do + it 'shows ticket state dropdown options in sorted order' do visit "ticket/zoom/#{ticket.id}" await_empty_ajax_queue - expect(all('select[name=state_id] option').map(&:text)).to eq(%w[geschlossen offen neu]) + expect(all('select[name=state_id] option').map(&:text)).to eq(%w[geschlossen neu offen]) end end @@ -935,7 +935,7 @@ RSpec.describe 'Ticket zoom', type: :system do let(:user) { create(:agent, groups: [permitted_group]) } let(:permitted_group) { create(:group) } - it 'shows ticket state dropdown options in sorted order, with new in sorted position' do + it 'shows ticket state dropdown options in sorted order' do visit 'ticket/create' await_empty_ajax_queue