fix(settings): Natural order groups

Signed-off-by: Christopher Ng <chrng8@gmail.com>
This commit is contained in:
Christopher Ng 2025-03-25 14:31:45 -07:00
parent e0cafe5fb1
commit 6ce464b899
3 changed files with 18 additions and 5 deletions

View file

@ -171,10 +171,8 @@ export default {
},
groups() {
// data provided php side + remove the recent and disabled groups
return this.$store.getters.getGroups
return this.$store.getters.getSortedGroups
.filter(group => group.id !== '__nc_internal_recent' && group.id !== 'disabled')
.sort((a, b) => a.name.localeCompare(b.name))
},
quotaOptions() {

View file

@ -12,6 +12,7 @@ import { loadState } from '@nextcloud/initial-state'
import axios from '@nextcloud/axios'
import { GroupSorting } from '../constants/GroupManagement.ts'
import { naturalCollator } from '../utils/sorting.ts'
import api from './api.js'
import logger from '../logger.ts'
@ -270,10 +271,10 @@ const getters = {
return groups.sort((a, b) => {
const numA = a.usercount - a.disabled
const numB = b.usercount - b.disabled
return (numA < numB) ? 1 : (numB < numA ? -1 : a.name.localeCompare(b.name))
return (numA < numB) ? 1 : (numB < numA ? -1 : naturalCollator.compare(a.name, b.name))
})
} else {
return groups.sort((a, b) => a.name.localeCompare(b.name))
return groups.sort((a, b) => naturalCollator.compare(a.name, b.name))
}
},
getGroupSorting(state) {

View file

@ -0,0 +1,14 @@
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { getCanonicalLocale, getLanguage } from '@nextcloud/l10n'
export const naturalCollator = Intl.Collator(
[getLanguage(), getCanonicalLocale()],
{
numeric: true,
usage: 'sort',
},
)