fix(settings): Natural order groups

Signed-off-by: Christopher Ng <chrng8@gmail.com>
pull/51336/head
Christopher Ng 1 month ago
parent eb60f6a7ba
commit 7c976a9605
  1. 4
      apps/settings/src/components/UserList.vue
  2. 5
      apps/settings/src/store/users.js
  3. 14
      apps/settings/src/utils/sorting.ts

@ -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() {

@ -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) {

@ -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',
},
)
Loading…
Cancel
Save