Show people surname first
Employee names now read "Winkler, Hannah" wherever a person appears in a list, a table, a heading or a tree node. That is the order a personnel list is kept in, it is the order people are looked up in, and it finally matches the sorting — the employee list has always been ordered by surname, which made an alphabetical page look unsorted. The name was being assembled inline in about twenty places. A rename that catches half of them is worse than none, so it now goes through fmtName in lib/format.ts and every display site calls it. Sentences keep the natural order: "Hannah Winkler wurde versetzt" reads like German, "Winkler, Hannah wurde versetzt" reads like a form. So the toasts are unchanged and only labels moved. Two things the change would have quietly broken: The org chart's own filter matched against "first last". It now matches either order, with or without the comma, so typing what you see works and so does typing what you remember. The print model sorted by the last word of the composed name, which happened to be the surname and is now the first name — every printed unit would have come out sorted by first name. It sorts on the surname field itself now, which is what it meant all along. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -56,8 +56,27 @@ export function initials(firstName: string, lastName: string): string {
|
||||
return `${a}${b}`;
|
||||
}
|
||||
|
||||
// "Dr. Max Mustermann, MSc MBA" — prefix titles precede the name, suffix
|
||||
// titles follow after a comma, both space-joined in the stored order.
|
||||
// „Mustermann, Max" — der Nachname zuerst.
|
||||
//
|
||||
// So steht es in jeder Personalliste, und danach wird gesucht: wer jemanden
|
||||
// sucht, hat den Nachnamen im Kopf. Nebenbei stimmt die Anzeige damit auch
|
||||
// mit der Sortierung überein, die schon immer nach Nachnamen ging — vorher
|
||||
// las sich eine alphabetische Liste, als wäre sie ungeordnet.
|
||||
//
|
||||
// Eine Stelle für alle: der Name wurde an gut zwanzig Orten einzeln
|
||||
// zusammengesetzt, und eine Umstellung, die die Hälfte davon vergisst, ist
|
||||
// schlimmer als gar keine.
|
||||
export function fmtName(firstName: string, lastName: string): string {
|
||||
const nach = lastName?.trim() ?? "";
|
||||
const vor = firstName?.trim() ?? "";
|
||||
if (!nach) return vor;
|
||||
if (!vor) return nach;
|
||||
return `${nach}, ${vor}`;
|
||||
}
|
||||
|
||||
// "Mustermann, Dr. Max, MSc MBA" — vorangestellte Titel stehen beim
|
||||
// Vornamen, nachgestellte am Ende. Der Nachname bleibt vorne, damit auch die
|
||||
// Überschrift einer Personalakte so beginnt wie ihr Eintrag in der Liste.
|
||||
export function fmtFullName(
|
||||
firstName: string,
|
||||
lastName: string,
|
||||
@@ -66,7 +85,7 @@ export function fmtFullName(
|
||||
): string {
|
||||
const prefix = titlePrefix && titlePrefix.length > 0 ? `${titlePrefix.join(" ")} ` : "";
|
||||
const suffix = titleSuffix && titleSuffix.length > 0 ? `, ${titleSuffix.join(" ")}` : "";
|
||||
return `${prefix}${firstName} ${lastName}${suffix}`;
|
||||
return `${fmtName(`${prefix}${firstName}`, lastName)}${suffix}`;
|
||||
}
|
||||
|
||||
// Whole years between two ISO dates. Compares the "MM-DD" tails as strings,
|
||||
|
||||
Reference in New Issue
Block a user