feat(editor+pdf): per-zone PDF sections + collapsible findings pickers
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
1e12f2252f
commit
de40c5f91e
3 files changed
+145
-33
No files matched your search
@@ -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<string | null>(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.'}
|
||||
</p>
|
||||
) : (
|
||||
<div className="space-y-4">
|
||||
{zonesWithTree.map(({ tree }) => (
|
||||
<div
|
||||
key={tree.id}
|
||||
className="rounded-xl border border-[var(--color-border)] p-3 bg-[var(--color-surface)]"
|
||||
>
|
||||
<div className="text-xs uppercase tracking-wide text-[var(--color-ink-muted)] mb-2">
|
||||
{tree.name_fr}
|
||||
</div>
|
||||
<FindingsTreePicker
|
||||
zoneId={tree.id}
|
||||
tree={tree}
|
||||
selected={observation.findings}
|
||||
onChange={(next) =>
|
||||
onChange({ ...observation, findings: next })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<ul className="space-y-2">
|
||||
{zonesWithTree.map(({ tree }) => {
|
||||
const expanded = expandedZoneId === tree.id
|
||||
const selectedCount = observation.findings.filter(
|
||||
(f) => f.zoneId === tree.id,
|
||||
).length
|
||||
return (
|
||||
<li
|
||||
key={tree.id}
|
||||
className={[
|
||||
'rounded-xl border bg-[var(--color-surface)] transition',
|
||||
expanded
|
||||
? 'border-[var(--color-accent)] ring-1 ring-[var(--color-accent)]'
|
||||
: 'border-[var(--color-border)]',
|
||||
].join(' ')}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
setExpandedZoneId(expanded ? null : tree.id)
|
||||
}
|
||||
aria-expanded={expanded}
|
||||
aria-controls={`findings-zone-${tree.id}`}
|
||||
className="w-full flex items-center justify-between gap-2 px-3 py-2 text-left rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]/40"
|
||||
>
|
||||
<span className="flex items-center gap-2">
|
||||
<span className="text-sm font-medium text-[var(--color-ink)]">
|
||||
{tree.name_fr}
|
||||
</span>
|
||||
{selectedCount > 0 && (
|
||||
<span
|
||||
aria-label={`${selectedCount} constat${selectedCount > 1 ? 's' : ''} sélectionné${selectedCount > 1 ? 's' : ''}`}
|
||||
className="inline-flex items-center justify-center min-w-[20px] h-[20px] px-1.5 rounded-full text-[11px] font-semibold bg-[var(--color-accent)] text-white"
|
||||
>
|
||||
{selectedCount}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className="text-[var(--color-ink-muted)]"
|
||||
>
|
||||
{expanded ? '▲' : '▼'}
|
||||
</span>
|
||||
</button>
|
||||
<AnimatePresence initial={false}>
|
||||
{expanded && (
|
||||
<motion.div
|
||||
key="picker-body"
|
||||
id={`findings-zone-${tree.id}`}
|
||||
initial={{ height: 0, opacity: 0 }}
|
||||
animate={{ height: 'auto', opacity: 1 }}
|
||||
exit={{ height: 0, opacity: 0 }}
|
||||
transition={{ duration: 0.18, ease: 'easeOut' }}
|
||||
className="overflow-hidden"
|
||||
>
|
||||
<div className="px-3 pb-3 pt-1 border-t border-[var(--color-border)]">
|
||||
<FindingsTreePicker
|
||||
zoneId={tree.id}
|
||||
tree={tree}
|
||||
selected={observation.findings}
|
||||
onChange={(next) =>
|
||||
onChange({ ...observation, findings: next })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</motion.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
)}
|
||||
</section>
|
||||
|
||||
|
||||
Reference in new issue
Block a user