feat(frontend): render honest precision dates in detail, list and search

Wires formatDocumentDate/DocumentDate into the read sites: the document
detail top bar + metadata drawer (the drawer shows the visible "Originaltext:"
raw line for UNKNOWN/SEASON/APPROX), the search/list rows (DocumentRow,
mobile + desktop), and the document multi-select dropdown label. A MONTH or
SEASON document now reads "Juni 1916"/"Sommer 1916" everywhere instead of a
fabricated day.

Adds metaDatePrecision to the DocumentRow/DocumentMultiSelect test fixtures
(required on DocumentListItem since #671) and updates the multi-select label
assertion to the honest long date.

Refs #666

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-27 11:56:49 +02:00
parent 6538c9e59a
commit b56b9dfa74
8 changed files with 86 additions and 19 deletions

View File

@@ -2,7 +2,8 @@
import type { components } from '$lib/generated/api';
import { m } from '$lib/paraglide/messages.js';
import { clickOutside } from '$lib/shared/actions/clickOutside';
import { formatDate } from '$lib/shared/utils/date';
import { formatDocumentDate, type DatePrecision } from '$lib/shared/utils/documentDate';
import { getLocale } from '$lib/paraglide/runtime.js';
type Document = components['schemas']['Document'];
type DocumentListItem = components['schemas']['DocumentListItem'];
@@ -49,7 +50,9 @@ function handleInput() {
const docs = body.items.map((it) => ({
id: it.id,
title: it.title,
documentDate: it.documentDate
documentDate: it.documentDate,
metaDatePrecision: it.metaDatePrecision,
metaDateEnd: it.metaDateEnd
})) as unknown as Document[];
results = docs.filter((d) => !selectedDocuments.some((s) => s.id === d.id));
}
@@ -73,8 +76,10 @@ function removeDocument(id: string | undefined) {
}
function formatDocLabel(doc: Document): string {
if (doc.documentDate) return `${doc.title} · ${formatDate(doc.documentDate, 'short')}`;
return doc.title;
if (!doc.documentDate) return doc.title;
const precision = (doc.metaDatePrecision as DatePrecision | undefined) ?? 'DAY';
const label = formatDocumentDate(doc.documentDate, precision, doc.metaDateEnd, null, getLocale());
return `${doc.title} · ${label}`;
}
</script>