feat(stammbaum): show inferred relationship in the document drawer

- New presentational RelationshipBadge component (labelFromA → arrow →
  labelFromB) wired into DocumentMetadataDrawer's Personen column,
  rendered after the receivers block when both endpoints are family
  members.
- DocumentTopBar gains an optional inferredRelationship prop and
  passes it through.
- documents/[id]/+page.server.ts loads the badge: only when sender is
  a family member, exactly one receiver, and that receiver is also a
  family member; 404 (no path) → null.
- relationshipLabels.ts maps the backend label keys (parent/child/...)
  to localised strings, so the server load returns badge-ready strings.

Refs #358.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-27 14:45:38 +02:00
committed by marcel
parent 6bed617959
commit b658a13247
6 changed files with 132 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ import { m } from '$lib/paraglide/messages.js';
import { formatDate } from '$lib/utils/date';
import { formatDocumentStatus } from '$lib/utils/documentStatusLabel';
import { getInitials, personAvatarColor } from '$lib/utils/personFormat';
import RelationshipBadge from '$lib/components/RelationshipBadge.svelte';
type Person = { id: string; firstName?: string | null; lastName: string; displayName: string };
type Tag = { id: string; name: string };
@@ -14,9 +15,18 @@ type Props = {
sender: Person | null;
receivers: Person[];
tags: Tag[];
inferredRelationship?: { labelFromA: string; labelFromB: string } | null;
};
let { documentDate, location, status, sender, receivers, tags }: Props = $props();
let {
documentDate,
location,
status,
sender,
receivers,
tags,
inferredRelationship = null
}: Props = $props();
const VISIBLE_RECEIVER_LIMIT = 5;
@@ -112,6 +122,12 @@ function getFullName(person: Person): string {
{/if}
</div>
{/if}
{#if inferredRelationship}
<RelationshipBadge
labelFromA={inferredRelationship.labelFromA}
labelFromB={inferredRelationship.labelFromB}
/>
{/if}
</div>
{:else}
<p class="font-serif text-sm text-ink-3">{m.doc_details_no_persons()}</p>