From de40c5f91e1b9bfbb222e21e966f843dda7451e9 Mon Sep 17 00:00:00 2001
From: Bastien Chanot
Date: Wed, 20 May 2026 05:07:03 +0200
Subject: [PATCH] feat(editor+pdf): per-zone PDF sections + collapsible
findings pickers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
PDF
---
The flat single-line "CONSTATS" section bundled every selected leaf
from every zone plus the free-text additions on one line, which got
hard to read as soon as an observation touched more than one zone.
The export now groups catalog findings by their JSON `zoneId` and
emits one section per zone, labelled with the zone's French name
("CONSTATS — SPHÉNOÏDE", "CONSTATS — ARTICULATION TEMPORO-MANDIBULAIRE
(ATM)", …). Free-text additions move to a dedicated "CONSTATS LIBRES"
section directly below.
The catalog tree is loaded once at the top of exportReportToPdf and
threaded through to addObservationPage, so the per-zone label lookup
costs nothing extra per observation.
Editor
------
Inside an expanded observation, each available zone's
FindingsTreePicker is now wrapped in an accordion header that mirrors
the ObservationCard expand/collapse semantics:
- Click a zone header → that picker opens and any other picker on the
card closes.
- Click an open zone header → it collapses.
- Each header shows a selected-count badge and a ▼/▲ caret.
Default state is "all closed" so the card stays compact when the user
expands a new observation. Motion-based height/opacity transition
matches the observation card body animation for visual consistency.
Co-Authored-By: Claude
---
.../observation/ObservationCard.tsx | 100 ++++++++++++++----
src/pdf/export.ts | 33 +++++-
src/pdf/render/observationPage.ts | 45 ++++++--
3 files changed, 145 insertions(+), 33 deletions(-)
diff --git a/src/components/observation/ObservationCard.tsx b/src/components/observation/ObservationCard.tsx
index 8df02387..cb3a9d62 100644
--- a/src/components/observation/ObservationCard.tsx
+++ b/src/components/observation/ObservationCard.tsx
@@ -1,4 +1,4 @@
-import { useMemo } from 'react'
+import { useMemo, useState } from 'react'
import type {
Observation,
ObservationZone,
@@ -66,6 +66,11 @@ export default function ObservationCard({
onOpenVertebraPicker,
onRemoveZone,
}: ObservationCardProps) {
+ // Per-zone picker accordion — only one tree picker open at a time,
+ // matching the observation-card accordion semantics. Closed by default
+ // so the card stays compact when first expanded.
+ const [expandedZoneId, setExpandedZoneId] = useState(null)
+
const zoneCount = observation.zones.length
const findingCount =
observation.findings.length + observation.freeTextFindings.length
@@ -262,26 +267,79 @@ export default function ObservationCard({
: 'Aucun référentiel disponible pour ces zones. Utilisez le texte libre ci-dessous.'}