Fixes #2528 - Manage -> Calendars -> Edit: "Subscribe to public holidays in" sorted wrong
This commit is contained in:
parent
ece077a503
commit
7726693dfb
3 changed files with 30 additions and 3 deletions
|
@ -3,7 +3,9 @@ class App.UiElement.ical_feed extends App.UiElement.ApplicationUiElement
|
||||||
@render: (attribute, params) ->
|
@render: (attribute, params) ->
|
||||||
|
|
||||||
icalFeeds = App.Config.get('ical_feeds') || {}
|
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 ) )
|
item = $( App.view('generic/ical_feed')( attribute: attribute, icalFeeds: icalFeedsSorted ) )
|
||||||
|
|
||||||
updateCheckList = ->
|
updateCheckList = ->
|
||||||
|
|
|
@ -1008,7 +1008,10 @@ class App.Utils
|
||||||
valueTmp = value.toString().toLowerCase()
|
valueTmp = value.toString().toLowerCase()
|
||||||
byNames.push valueTmp
|
byNames.push valueTmp
|
||||||
byNamesWithValue[valueTmp] = [i, value]
|
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
|
# do a reverse, if needed
|
||||||
if order == 'DESC'
|
if order == 'DESC'
|
||||||
|
|
|
@ -46,4 +46,26 @@ RSpec.describe 'Manage > Calendars', type: :system do
|
||||||
end
|
end
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue