feat(person): add birth year and death year fields #18

Closed
opened 2026-03-19 21:13:15 +01:00 by marcel · 0 comments
Owner

User Journey

Marie is researching her great-grandmother Hedwig. She opens the person page and wants to understand who Hedwig was before reading any documents. Currently the page shows only a name — no indication of when Hedwig lived. Marie has to piece together the timeline from individual documents.

With this feature, Marie sees " 1889 · † 1952"* directly under the name. She immediately understands the historical context before reading a single letter.


High-Level Plan

Add two optional integer fields birthYear and deathYear to the Person entity. Expose them in the edit form and display them in view mode. No complex date logic — years only.

Layers touched: Flyway migration → JPA entity → DTO → OpenAPI types → frontend form + display.


Detailed Plan

Backend

  1. Migration V{n}__add_person_birth_death_years.sql:

    ALTER TABLE persons ADD COLUMN birth_year INT;
    ALTER TABLE persons ADD COLUMN death_year INT;
    
  2. Person entity — add two nullable fields:

    @Schema(description = "Year of birth")
    private Integer birthYear;
    
    @Schema(description = "Year of death")
    private Integer deathYear;
    
  3. PersonUpdateDTO — add optional fields:

    private Integer birthYear;
    private Integer deathYear;
    
  4. PersonService.update() — map the new fields from DTO to entity.

  5. Rebuild JAR and run npm run generate:api in frontend/.

Frontend

  1. Edit form (persons/[id]/+page.svelte) — add two number inputs in a new row:

    • "Geburtsjahr" (birthYear, type=number, min=1000, max=2100, optional)
    • "Sterbejahr" (deathYear, same constraints, optional)
  2. View mode — display below the name if present:

    * 1889  ·  † 1952
    

    Hide the row entirely when both are null.

  3. +page.server.ts update action — parse and forward birthYear / deathYear from form data.

Acceptance Criteria

  • Both fields are optional — existing persons are unaffected
  • Edit form accepts 4-digit years, rejects non-numeric input
  • View mode shows birth/death only when at least one is set
  • birthYear > deathYear shows a validation error on save
  • Person list page is unaffected (no year shown there)
## User Journey Marie is researching her great-grandmother Hedwig. She opens the person page and wants to understand who Hedwig was before reading any documents. Currently the page shows only a name — no indication of when Hedwig lived. Marie has to piece together the timeline from individual documents. With this feature, Marie sees **"* 1889 · † 1952"** directly under the name. She immediately understands the historical context before reading a single letter. --- ## High-Level Plan Add two optional integer fields `birthYear` and `deathYear` to the `Person` entity. Expose them in the edit form and display them in view mode. No complex date logic — years only. **Layers touched:** Flyway migration → JPA entity → DTO → OpenAPI types → frontend form + display. --- ## Detailed Plan ### Backend 1. **Migration** `V{n}__add_person_birth_death_years.sql`: ```sql ALTER TABLE persons ADD COLUMN birth_year INT; ALTER TABLE persons ADD COLUMN death_year INT; ``` 2. **`Person` entity** — add two nullable fields: ```java @Schema(description = "Year of birth") private Integer birthYear; @Schema(description = "Year of death") private Integer deathYear; ``` 3. **`PersonUpdateDTO`** — add optional fields: ```java private Integer birthYear; private Integer deathYear; ``` 4. **`PersonService.update()`** — map the new fields from DTO to entity. 5. Rebuild JAR and run `npm run generate:api` in `frontend/`. ### Frontend 6. **Edit form** (`persons/[id]/+page.svelte`) — add two number inputs in a new row: - "Geburtsjahr" (`birthYear`, type=number, min=1000, max=2100, optional) - "Sterbejahr" (`deathYear`, same constraints, optional) 7. **View mode** — display below the name if present: ``` * 1889 · † 1952 ``` Hide the row entirely when both are null. 8. **`+page.server.ts` `update` action** — parse and forward `birthYear` / `deathYear` from form data. ### Acceptance Criteria - [ ] Both fields are optional — existing persons are unaffected - [ ] Edit form accepts 4-digit years, rejects non-numeric input - [ ] View mode shows birth/death only when at least one is set - [ ] `birthYear > deathYear` shows a validation error on save - [ ] Person list page is unaffected (no year shown there)
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: marcel/familienarchiv#18