Fixes #3335 - state list of tickets ignore locale for their sorting.

This commit is contained in:
Romit Choudhary 2021-05-21 09:38:54 +00:00 committed by Thorsten Eckel
parent ff8723d4ca
commit 628089c2cd
3 changed files with 42 additions and 5 deletions

View file

@ -115,7 +115,7 @@ class App.UiElement.ApplicationUiElement
App.Log.debug 'ControllerForm', '_getRelationOptionList:filter-array', attribute.filter App.Log.debug 'ControllerForm', '_getRelationOptionList:filter-array', attribute.filter
# check all records # 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 # check all filter attributes
for key in attribute.filter for key in attribute.filter

View file

@ -778,8 +778,9 @@ set new attributes of model (remove already available attributes)
all_complied = @_filterExtended(all_complied, params.filterExtended) all_complied = @_filterExtended(all_complied, params.filterExtended)
# sort by # sort by
# if translate true then use translated strings to sort list
if params.sortBy != null if params.sortBy != null
all_complied = @_sortBy(all_complied, params.sortBy) all_complied = @_sortBy(all_complied, params.sortBy, params.translate)
# order # order
if params.order if params.order
@ -787,7 +788,7 @@ set new attributes of model (remove already available attributes)
all_complied all_complied
@_sortBy: (collection, attribute) -> @_sortBy: (collection, attribute, translate) ->
_.sortBy(collection, (item) -> _.sortBy(collection, (item) ->
# set displayName as default sort attribute # set displayName as default sort attribute
@ -797,7 +798,9 @@ set new attributes of model (remove already available attributes)
# check if displayName exists # check if displayName exists
if attribute is 'displayName' if attribute is 'displayName'
if item.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 else
attribute = 'name' attribute = 'name'
@ -806,7 +809,9 @@ set new attributes of model (remove already available attributes)
# return value if string # return value if string
if item[ attribute ].toLowerCase 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 ] item[ attribute ]
) )

View file

@ -920,6 +920,38 @@ RSpec.describe 'Ticket zoom', type: :system do
end end
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 context 'object manager attribute permission view' do
let!(:group_users) { Group.find_by(name: 'Users') } let!(:group_users) { Group.find_by(name: 'Users') }