fix(accidentForm): update sorting logic to prioritize first name over last name

- Modified the availableMembers computed property to sort filtered members alphabetically by first name first, followed by last name, ensuring a more intuitive display order.
- Updated logging to reflect the new sorting format in the output.
This commit is contained in:
Torsten Schulz (local)
2026-01-14 14:27:27 +01:00
parent 23caeddf9e
commit e21b50fc38

View File

@@ -112,21 +112,21 @@ export default {
const filtered = this.members.filter(m => participantSet.has(m.id));
console.log('[AccidentFormDialog] filtered.length:', filtered.length);
// Alphabetisch sortieren nach Nachname, dann Vorname
// Alphabetisch sortieren nach Vorname, dann Nachname (entspricht der Anzeige)
// Erstelle ein neues Array, um Reaktivitätsprobleme zu vermeiden
const sorted = filtered.slice().sort((a, b) => {
const lastNameA = (a.lastName || '').trim().toLowerCase();
const lastNameB = (b.lastName || '').trim().toLowerCase();
if (lastNameA !== lastNameB) {
return lastNameA.localeCompare(lastNameB, 'de', { sensitivity: 'base' });
}
const firstNameA = (a.firstName || '').trim().toLowerCase();
const firstNameB = (b.firstName || '').trim().toLowerCase();
return firstNameA.localeCompare(firstNameB, 'de', { sensitivity: 'base' });
if (firstNameA !== firstNameB) {
return firstNameA.localeCompare(firstNameB, 'de', { sensitivity: 'base' });
}
const lastNameA = (a.lastName || '').trim().toLowerCase();
const lastNameB = (b.lastName || '').trim().toLowerCase();
return lastNameA.localeCompare(lastNameB, 'de', { sensitivity: 'base' });
});
console.log('[AccidentFormDialog] availableMembers computed - end, result.length:', sorted.length);
console.log('[AccidentFormDialog] First 3 sorted:', sorted.slice(0, 3).map(m => `${m.lastName}, ${m.firstName}`));
console.log('[AccidentFormDialog] First 3 sorted:', sorted.slice(0, 3).map(m => `${m.firstName} ${m.lastName}`));
return sorted;
},
isValid() {