feat(fp): brief v3 — besluit-driven guided drafting

Compose the herregistratie letter from the besluit instead of a library hunt:
the behandelaar picks positief/negatief (+ reden-checkboxes for a negatief) and
the kern's standaardteksten follow the selection live.

Front-end (this increment):
- Kern is recomposed reactively from the besluit selection (new BesluitSelected
  machine msg + composeKern); the "Genereer conceptbrief" button is gone. The
  drafter's free text is preserved across a selection change.
- The editor shows only the editable sections; the locked aanhef/slot render in
  the preview, not the authoring surface. Slot is a case-type template section
  (per templateId), documented as such.
- The panel re-seeds from the letter via inferSelection() — the besluit + redenen
  are read back off the kern's passage blocks, so the selection survives reload
  with no new wire fields (derive, don't store).
- letter-section drops the now-redundant per-section passage picker (besluit owns
  standaardteksten); keeps free-text + block edit/move/remove.

Fix: app-checkbox now falls back to a unique per-instance id when checkboxId is
omitted. The CIBG styled checkbox routes clicks through the label, so the shared
id="undefined" made every reason label toggle the first input — the second
checkbox could never be checked. Verified live (Playwright): each reason toggles
independently.

Backend/seam (brief v3 WIP): besluit/reason passage tags on the wire + seed,
carried through the adapter parse boundary.

Specs updated (besluit, brief.machine) and the affected stories re-pointed at the
new API. FE lint + build + 253 vitest specs green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
eho
2026-07-20 18:53:53 +02:00
co-authored by Claude Opus 4.8
parent 62ba0b98c4
commit ba32e3dd9f
31 changed files with 4900 additions and 2878 deletions
+25 -1
View File
@@ -7,6 +7,7 @@ import {
BriefDto,
BriefStatusDto,
BriefViewDto,
CaseContextDto,
LetterBlockDto,
LetterSectionDto,
LibraryPassageDto,
@@ -19,6 +20,7 @@ import {
Brief,
BriefDecisions,
BriefStatus,
CaseContext,
LetterBlock,
LetterSection,
LibraryPassage,
@@ -40,6 +42,7 @@ export interface BriefView {
readonly availablePassages: LibraryPassage[];
readonly decisions: BriefDecisions;
readonly orgTemplate: OrgTemplate;
readonly caseContext: CaseContext;
}
export const BRIEF_LOAD_FAILED = $localize`:@@brief.load.failed:De brief kon niet worden geladen.`;
@@ -249,7 +252,25 @@ function parsePassage(dto: LibraryPassageDto): Result<string, LibraryPassage> {
content: content.value,
version: dto.version,
...(dto.beroep != null ? { beroep: dto.beroep } : {}),
...(dto.isDefault ? { isDefault: true } : {}),
...(dto.besluit === 'positief' || dto.besluit === 'negatief' ? { besluit: dto.besluit } : {}),
...(dto.reason != null ? { reason: dto.reason } : {}),
});
}
function parseCaseContext(dto: CaseContextDto | undefined): Result<string, CaseContext> {
if (
typeof dto?.zorgverlenerNaam !== 'string' ||
typeof dto.bigNummer !== 'string' ||
typeof dto.beroep !== 'string' ||
typeof dto.aanvraagReferentie !== 'string'
) {
return err('brief-view: missing/invalid case context');
}
return ok({
zorgverlenerNaam: dto.zorgverlenerNaam,
bigNummer: dto.bigNummer,
beroep: dto.beroep,
aanvraagReferentie: dto.aanvraagReferentie,
});
}
@@ -351,6 +372,8 @@ export function parseBriefView(dto: BriefViewDto): Result<string, BriefView> {
if (!decisions.ok) return decisions;
const orgTemplate = parseOrgTemplate(dto.orgTemplate);
if (!orgTemplate.ok) return orgTemplate;
const caseContext = parseCaseContext(dto.caseContext);
if (!caseContext.ok) return caseContext;
const availablePassages: LibraryPassage[] = [];
for (const p of dto.availablePassages ?? []) {
const parsed = parsePassage(p);
@@ -362,6 +385,7 @@ export function parseBriefView(dto: BriefViewDto): Result<string, BriefView> {
availablePassages,
decisions: decisions.value,
orgTemplate: orgTemplate.value,
caseContext: caseContext.value,
});
}