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:
@@ -6,10 +6,10 @@ import StarterKit from '@tiptap/starter-kit';
|
||||
import { m } from '$lib/paraglide/messages.js';
|
||||
import type { components } from '$lib/generated/api';
|
||||
import GeschichteSidebar from '$lib/geschichte/GeschichteSidebar.svelte';
|
||||
import { toPersonOption, type PersonOption } from '$lib/person/personOption';
|
||||
|
||||
type GeschichteView = components['schemas']['GeschichteView'];
|
||||
type Person = components['schemas']['Person'];
|
||||
type PersonOption = Pick<Person, 'id' | 'displayName'>;
|
||||
|
||||
interface Props {
|
||||
geschichte?: GeschichteView | null;
|
||||
@@ -33,12 +33,7 @@ let title = $state(geschichte?.title ?? '');
|
||||
let body = $state(geschichte?.body ?? '');
|
||||
let status: 'DRAFT' | 'PUBLISHED' = $state(geschichte?.status ?? 'DRAFT');
|
||||
let selectedPersons: PersonOption[] = $state(
|
||||
geschichte?.persons
|
||||
? Array.from(geschichte.persons).map((p) => ({
|
||||
id: p.id,
|
||||
displayName: [p.firstName, p.lastName].filter(Boolean).join(' ')
|
||||
}))
|
||||
: initialPersons
|
||||
geschichte?.persons ? Array.from(geschichte.persons).map(toPersonOption) : initialPersons
|
||||
);
|
||||
|
||||
let dirty = $state(false);
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { m } from '$lib/paraglide/messages.js';
|
||||
import type { components } from '$lib/generated/api';
|
||||
import PersonMultiSelect from '$lib/person/PersonMultiSelect.svelte';
|
||||
|
||||
type Person = components['schemas']['Person'];
|
||||
type PersonOption = Pick<Person, 'id' | 'displayName'>;
|
||||
import type { PersonOption } from '$lib/person/personOption';
|
||||
|
||||
interface Props {
|
||||
status: 'DRAFT' | 'PUBLISHED';
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { components } from '$lib/generated/api';
|
||||
import { m } from '$lib/paraglide/messages.js';
|
||||
import { csrfFetch } from '$lib/shared/cookies';
|
||||
import { createBlockDragDrop } from '$lib/document/transcription/useBlockDragDrop.svelte';
|
||||
import { toPersonOption, type PersonOption } from '$lib/person/personOption';
|
||||
import { createUnsavedWarning } from '$lib/shared/hooks/useUnsavedWarning.svelte';
|
||||
import type { DocumentOption } from '$lib/document/documentTypeahead';
|
||||
import GeschichteSidebar from './GeschichteSidebar.svelte';
|
||||
@@ -11,7 +12,6 @@ import JourneyAddBar from './JourneyAddBar.svelte';
|
||||
|
||||
type GeschichteView = components['schemas']['GeschichteView'];
|
||||
type JourneyItemView = components['schemas']['JourneyItemView'];
|
||||
type Person = components['schemas']['Person'];
|
||||
|
||||
interface Props {
|
||||
geschichte: GeschichteView;
|
||||
@@ -31,7 +31,9 @@ const unsaved = createUnsavedWarning();
|
||||
let title = $state(geschichte.title ?? '');
|
||||
let body = $state(geschichte.body ?? '');
|
||||
let status: 'DRAFT' | 'PUBLISHED' = $state(geschichte.status ?? 'DRAFT');
|
||||
let selectedPersons: Person[] = $state(geschichte.persons ? Array.from(geschichte.persons) : []);
|
||||
let selectedPersons: PersonOption[] = $state(
|
||||
geschichte.persons ? Array.from(geschichte.persons).map(toPersonOption) : []
|
||||
);
|
||||
let items: JourneyItemView[] = $state(
|
||||
[...(geschichte.items ?? [])].sort((a, b) => a.position - b.position)
|
||||
);
|
||||
|
||||
@@ -394,3 +394,18 @@ describe('JourneyEditor — duplicate document aria-disabled', () => {
|
||||
expect(option.getAttribute('aria-disabled')).toBe('true');
|
||||
});
|
||||
});
|
||||
|
||||
describe('JourneyEditor — person chips from GeschichteView', () => {
|
||||
it('renders person names in the sidebar chips (PersonView carries no displayName)', async () => {
|
||||
render(
|
||||
JourneyEditor,
|
||||
defaultProps({
|
||||
geschichte: makeGeschichte({
|
||||
persons: [{ id: 'p1', firstName: 'Anna', lastName: 'Schmidt' }]
|
||||
})
|
||||
})
|
||||
);
|
||||
|
||||
await expect.element(page.getByText('Anna Schmidt')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user