Fixes #2528 - Manage -> Calendars -> Edit: "Subscribe to public holidays in" sorted wrong

This commit is contained in:
Romit Choudhary 2021-09-07 11:16:01 +02:00 committed by Thorsten Eckel
parent ece077a503
commit 7726693dfb
3 changed files with 30 additions and 3 deletions

View file

@ -3,7 +3,9 @@ class App.UiElement.ical_feed extends App.UiElement.ApplicationUiElement
@render: (attribute, params) ->
icalFeeds = App.Config.get('ical_feeds') || {}
icalFeedsSorted = App.Utils.sortByValue(icalFeeds)
icalFeedsTranslated = _.mapObject icalFeeds, (value, key) -> App.i18n.translateContent(value)
icalFeedsSorted = App.Utils.sortByValue(icalFeedsTranslated)
item = $( App.view('generic/ical_feed')( attribute: attribute, icalFeeds: icalFeedsSorted ) )
updateCheckList = ->

View file

@ -1008,7 +1008,10 @@ class App.Utils
valueTmp = value.toString().toLowerCase()
byNames.push valueTmp
byNamesWithValue[valueTmp] = [i, value]
byNames = byNames.sort()
# sort() by default doesn't compare non-ascii characters such as ['é', 'a', 'ú', 'c']
# hence using localecompare in sorting for translated strings
byNames = byNames.sort((a, b) -> a.localeCompare(b))
# do a reverse, if needed
if order == 'DESC'

View file

@ -46,4 +46,26 @@ RSpec.describe 'Manage > Calendars', type: :system do
end
end
end
# https://github.com/zammad/zammad/issues/2528
context 'ical feed - subscribe to public holidays in another country' do
it 'shows countries dropdown in sorted order' do
allow(Calendar).to receive(:ical_feeds).and_return({
'https://argentinien.de': 'Argentinien',
'https://australien.de': 'Australien',
'https://osterreich.de': 'Österreich',
'https://weibrussland.de': 'Weißrussland',
'https://kanada.de': 'Kanada',
'https://chile.de': 'Chile',
})
visit '/#manage/calendars'
click '.js-new'
in_modal disappears: false do
expect(all('.ical_feed select option').map(&:text)).to eq ['-', 'Argentinien', 'Australien', 'Chile', 'Kanada', 'Österreich', 'Weißrussland']
end
end
end
end