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 908be1ad7..23baba2ed 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 @@ -115,7 +115,7 @@ class App.UiElement.ApplicationUiElement App.Log.debug 'ControllerForm', '_getRelationOptionList:filter-array', attribute.filter # check all records - for record in App[ attribute.relation ].search(sortBy: attribute.sortBy) + for record in App[ attribute.relation ].search(sortBy: attribute.sortBy, translate: attribute.translate) # check all filter attributes for key in attribute.filter diff --git a/app/assets/javascripts/app/models/_application_model.coffee b/app/assets/javascripts/app/models/_application_model.coffee index a9370e0b1..f80aae679 100644 --- a/app/assets/javascripts/app/models/_application_model.coffee +++ b/app/assets/javascripts/app/models/_application_model.coffee @@ -778,8 +778,9 @@ set new attributes of model (remove already available attributes) all_complied = @_filterExtended(all_complied, params.filterExtended) # sort by + # if translate true then use translated strings to sort list if params.sortBy != null - all_complied = @_sortBy(all_complied, params.sortBy) + all_complied = @_sortBy(all_complied, params.sortBy, params.translate) # order if params.order @@ -787,7 +788,7 @@ set new attributes of model (remove already available attributes) all_complied - @_sortBy: (collection, attribute) -> + @_sortBy: (collection, attribute, translate) -> _.sortBy(collection, (item) -> # set displayName as default sort attribute @@ -797,7 +798,9 @@ set new attributes of model (remove already available attributes) # check if displayName exists if attribute is 'displayName' if item.displayName - return item.displayName().toLowerCase() + value = item.displayName() + valueProcessed = if translate then App.i18n.translateInline(value) else value + return valueProcessed.toLowerCase() else attribute = 'name' @@ -806,7 +809,9 @@ set new attributes of model (remove already available attributes) # return value if string if item[ attribute ].toLowerCase - return item[ attribute ].toLowerCase() + value = item[ attribute ] + valueProcessed = if translate then App.i18n.translateInline(value) else value + return valueProcessed.toLowerCase() item[ attribute ] ) diff --git a/spec/system/ticket/zoom_spec.rb b/spec/system/ticket/zoom_spec.rb index 085706104..e631cc630 100644 --- a/spec/system/ticket/zoom_spec.rb +++ b/spec/system/ticket/zoom_spec.rb @@ -920,6 +920,38 @@ RSpec.describe 'Ticket zoom', type: :system do end end + # https://github.com/zammad/zammad/issues/3335 + context 'ticket state sort order maintained when locale is de-de', authenticated_as: :authenticate do + def authenticate + user.preferences[:locale] = 'de-de' + user + end + + context 'when existing ticket is open' 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 + visit "ticket/zoom/#{ticket.id}" + + await_empty_ajax_queue + expect(all('select[name=state_id] option').map(&:text)).to eq(%w[geschlossen offen neu]) + end + end + + context 'when a new ticket is created' 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 + visit 'ticket/create' + + await_empty_ajax_queue + expect(all('select[name=state_id] option').map(&:text)).to eq ['-', 'geschlossen', 'neu', 'offen', 'warten auf Erinnerung', 'warten auf schliessen'] + end + end + end + context 'object manager attribute permission view' do let!(:group_users) { Group.find_by(name: 'Users') }