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

@@ -1,17 +1,32 @@
<script lang="ts">
import { formatDate } from '$lib/shared/utils/date';
import { formatDocumentDate, type DatePrecision } from '$lib/shared/utils/documentDate';
import { getLocale } from '$lib/paraglide/runtime.js';
type Props = {
title?: string | null;
originalFilename?: string | null;
documentDate?: string | null;
metaDatePrecision?: DatePrecision | null;
metaDateEnd?: string | null;
metaDateRaw?: string | null;
};
let { title, originalFilename, documentDate }: Props = $props();
let {
title,
originalFilename,
documentDate,
metaDatePrecision = null,
metaDateEnd = null,
metaDateRaw = null
}: Props = $props();
const displayTitle = $derived(title || originalFilename || '');
const shortDate = $derived(documentDate ? formatDate(documentDate, 'short') : null);
const longDate = $derived(documentDate ? formatDate(documentDate, 'long') : null);
const precision = $derived<DatePrecision>(metaDatePrecision ?? (documentDate ? 'DAY' : 'UNKNOWN'));
const dateLabel = $derived(
documentDate
? formatDocumentDate(documentDate, precision, metaDateEnd, metaDateRaw, getLocale())
: null
);
</script>
<div class="min-w-0 flex-1 overflow-hidden">
@@ -21,10 +36,7 @@ const longDate = $derived(documentDate ? formatDate(documentDate, 'long') : null
>
{displayTitle}
</h1>
{#if shortDate}
<p class="font-sans text-[16px] text-ink-2">
<span class="lg:hidden">{shortDate}</span>
<span class="hidden lg:inline">{longDate}</span>
</p>
{#if dateLabel}
<p class="font-sans text-[16px] text-ink-2">{dateLabel}</p>
{/if}
</div>