Correct alphabetical sort of names in Org Admin panel. Supports Last, First and First Last + variatioons.

This commit is contained in:
2026-02-19 20:54:52 +00:00
parent 1806bcab5c
commit c1b2bcf76c
+15 -3
View File
@@ -36,14 +36,26 @@ const orgPermissions = computed(() => {
}) })
// Get users for a role as sorted array of { uuid, ...user } // Get users for a role as sorted array of { uuid, ...user }
function getNormalizedName(name) {
let cleaned = name.replace(/\([^)]*\)/g, '').trim();
if (cleaned.includes(',')) {
return cleaned.toLowerCase();
} else {
const parts = cleaned.split(/\s+/);
const last = parts.pop();
const first = parts.join(' ');
return `${last}, ${first}`.toLowerCase();
}
}
function roleUsers(roleUuid) { function roleUsers(roleUuid) {
return Object.entries(props.selectedOrg.users) return Object.entries(props.selectedOrg.users)
.filter(([_, u]) => u.role === roleUuid) .filter(([_, u]) => u.role === roleUuid)
.map(([uuid, u]) => ({ uuid, ...u })) .map(([uuid, u]) => ({ uuid, ...u }))
.sort((a, b) => { .sort((a, b) => {
const nameA = a.display_name.toLowerCase() const normA = getNormalizedName(a.display_name);
const nameB = b.display_name.toLowerCase() const normB = getNormalizedName(b.display_name);
return nameA.localeCompare(nameB) return normA.localeCompare(normB);
}) })
} }