feat(person): date + precision controls on person new/edit forms

New PersonLifeDateField (German date input + hidden ISO + DAY/MONTH/YEAR
precision select, min-h-44px, sm: side-by-side) used for birth and death
in both forms. Legacy APPROX precision seeds the select as YEAR so an
untouched save never claims DAY. Server actions send date+precision
pairs or omit both; obsolete year i18n keys removed, 9 form keys added.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-06-12 18:20:18 +02:00
parent 4dcf8e2242
commit 9664a83dae
10 changed files with 258 additions and 89 deletions

View File

@@ -1,6 +1,7 @@
import { error, fail, redirect } from '@sveltejs/kit';
import { createApiClient, extractErrorCode } from '$lib/shared/api.server';
import { getErrorMessage } from '$lib/shared/errors';
import type { DatePrecision } from '$lib/shared/utils/documentDate';
import {
normalizePersonType,
validatePersonFields,
@@ -47,10 +48,17 @@ export const actions = {
const lastName = formData.get('lastName')?.toString().trim();
const alias = formData.get('alias')?.toString().trim() || undefined;
const notes = formData.get('notes')?.toString().trim() || undefined;
const birthYearStr = formData.get('birthYear')?.toString().trim();
const deathYearStr = formData.get('deathYear')?.toString().trim();
const birthYear = birthYearStr ? parseInt(birthYearStr, 10) : undefined;
const deathYear = deathYearStr ? parseInt(deathYearStr, 10) : undefined;
// Empty date input → omit date AND precision: the backend normalises the
// absent pair to null/UNKNOWN, and a lone precision would fail the
// coherence check (INVALID_DATE_PRECISION).
const birthDate = formData.get('birthDate')?.toString().trim() || undefined;
const birthDatePrecision = birthDate
? (formData.get('birthDatePrecision')?.toString() as DatePrecision)
: undefined;
const deathDate = formData.get('deathDate')?.toString().trim() || undefined;
const deathDatePrecision = deathDate
? (formData.get('deathDatePrecision')?.toString() as DatePrecision)
: undefined;
// Must NOT use the conditional-spread idiom for generation: G 0 is a
// valid family-tree-root value. The key always travels in the body so
// an explicit clear (empty option) reaches the backend as null.
@@ -73,8 +81,8 @@ export const actions = {
lastName,
...(alias ? { alias } : {}),
...(notes ? { notes } : {}),
...(birthYear ? { birthYear } : {}),
...(deathYear ? { deathYear } : {}),
...(birthDate ? { birthDate, birthDatePrecision } : {}),
...(deathDate ? { deathDate, deathDatePrecision } : {}),
generation
}
});