fix(journey): person chips rendered blank — share one PersonView→PersonOption projection
JourneyEditor fed GeschichteView.PersonView (no displayName) straight into the displayName-rendering PersonMultiSelect, so every chip on a journey was empty. The name mapping both editors need now lives once in $lib/person/personOption.ts (with the [Unbekannt] fallback matching GeschichteService.toView), and PersonMultiSelect/GeschichteSidebar import the narrow PersonOption contract from there. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,10 +2,8 @@
|
||||
import type { components } from '$lib/generated/api';
|
||||
import { m } from '$lib/paraglide/messages.js';
|
||||
import { clickOutside } from '$lib/shared/actions/clickOutside';
|
||||
import type { PersonOption } from './personOption';
|
||||
type Person = components['schemas']['Person'];
|
||||
// Narrow contract: only what the chips render and dedup needs. Full Person
|
||||
// objects from /api/persons remain assignable; view projections fit too.
|
||||
type PersonOption = Pick<Person, 'id' | 'displayName'>;
|
||||
|
||||
interface Props {
|
||||
selectedPersons?: PersonOption[];
|
||||
|
||||
26
frontend/src/lib/person/personOption.ts
Normal file
26
frontend/src/lib/person/personOption.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import type { components } from '$lib/generated/api';
|
||||
|
||||
type Person = components['schemas']['Person'];
|
||||
|
||||
/**
|
||||
* Narrow chip/dedup contract for person pickers: exactly what PersonMultiSelect
|
||||
* renders. Full `Person` objects (search results) are structurally assignable;
|
||||
* view projections without a displayName go through {@link toPersonOption}.
|
||||
*/
|
||||
export type PersonOption = Pick<Person, 'id' | 'displayName'>;
|
||||
|
||||
/**
|
||||
* Maps a name-carrying projection (e.g. GeschichteView.PersonView, which has no
|
||||
* server-computed displayName) into the chip contract. Mirrors the server-side
|
||||
* fallback in GeschichteService.toView.
|
||||
*/
|
||||
export function toPersonOption(p: {
|
||||
id: string;
|
||||
firstName?: string | null;
|
||||
lastName?: string | null;
|
||||
}): PersonOption {
|
||||
return {
|
||||
id: p.id,
|
||||
displayName: [p.firstName, p.lastName].filter(Boolean).join(' ') || '[Unbekannt]'
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user