feat(geschichten): chip-row UI for multi-person AND filter

The /geschichten list page now renders one removable chip per active
person filter and lets users add more via the existing typeahead. The
URL uses repeated ?personId= params (matching the documents tag
filter), which the regenerated API client passes straight through to
the backend's new array-bound endpoint. New translation keys cover the
chip remove aria-label, the AND hint shown while picking, and the
multi-person empty state.
This commit is contained in:
Marcel
2026-05-03 08:37:28 +02:00
parent 0802889ea9
commit 96d023a7cb
7 changed files with 171 additions and 36 deletions

View File

@@ -1,26 +1,27 @@
import { error } from '@sveltejs/kit';
import { createApiClient } from '$lib/api.server';
import { getErrorMessage } from '$lib/errors';
import type { components } from '$lib/generated/api';
import type { PageServerLoad } from './$types';
type Person = components['schemas']['Person'];
export const load: PageServerLoad = async ({ url, fetch }) => {
const api = createApiClient(fetch);
const personId = url.searchParams.get('personId') ?? undefined;
const personIds = url.searchParams.getAll('personId');
const documentId = url.searchParams.get('documentId') ?? undefined;
const [listResult, personResult] = await Promise.all([
const [listResult, ...personResults] = await Promise.all([
api.GET('/api/geschichten', {
params: {
query: {
status: 'PUBLISHED',
personId,
personId: personIds.length ? personIds : undefined,
documentId
}
}
}),
personId
? api.GET('/api/persons/{id}', { params: { path: { id: personId } } })
: Promise.resolve(null)
...personIds.map((id) => api.GET('/api/persons/{id}', { params: { path: { id } } }))
]);
if (!listResult.response.ok) {
@@ -28,9 +29,13 @@ export const load: PageServerLoad = async ({ url, fetch }) => {
throw error(listResult.response.status, getErrorMessage(code));
}
const personFilters = personResults
.filter((r) => r && r.response.ok && r.data)
.map((r) => r!.data!) as Person[];
return {
geschichten: listResult.data ?? [],
personFilter: personResult && personResult.response.ok ? personResult.data! : null,
personFilters,
documentFilter: documentId ?? null
};
};