refactor(anatomy): adapt parser to new SVG convention (categories + single-element)

User dropped new Horse.svg / Horse_head.svg that follow a simpler
convention:

- Categories renamed to longer human strings:
    articulation       → articulations
    charniere          → charni-res-vert-brales
    spine-zone         → zone-colonne
    cadran-crane       → cadrans-du-cr-ne
    head, os-overlay   → dropped (head zone is now category="os" + data-anno-opens-detail)
    os                 → unchanged
- No more hitbox / visible class split; multiple elements may still share
  the same data-anno-id but they all carry the same role.
- Trigger-only zones (`data-anno-opens-detail="head"`) may omit
  `data-anno-name-fr/en`.

Changes:
- `Bone` now exposes a single `els: Element[]` instead of `hitboxEls +
  visibleEls`.
- `parseSvgBones` accepts annotations without fr/en labels (defaults to
  empty string) but still rejects unknown or missing categories.
- The "interactive vs decorative" filter is gone — every parsed
  annotation is interactive, since the new SVGs only annotate the
  clickable zones.
- Vertebra-picker trigger: `bone.category === 'zone-colonne'`
  (EditorRoute + ObservationCard).
- PDF colorisation in `observationPage.colorizedSvgString` writes the
  accent fill to every `els[]` entry (no more hitbox dual-pass).
- Dead `src/components/observation/ObservationEditor.tsx` removed (its
  body lives inside ObservationCard since the accordion refactor).
- Tests rewritten for the new vocabulary; synthetic fixture uses the new
  categories, real-SVG test asserts 18 + 9 unique zones.

92/92 tests pass, lint clean, build clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Bastien ChanotandClaude Opus 4.7 committed 2026-05-19 04:06:26 +02:00
1 parent 1109e33383
commit cad94a49db
10 files changed
+325 -428

No files matched your search

@@ -187,7 +187,7 @@ export default function ObservationCard({
<ul className="flex flex-wrap gap-2">
{observation.zones.map((z, i) => {
const b = bones.get(z.boneId)
const isSpine = b?.category === 'spine-zone'
const isSpine = b?.category === 'zone-colonne'
return (
<li key={`${z.boneId}-${i}`}>
<Badge tone="accent" className="gap-2">
@@ -1,126 +0,0 @@
import { useMemo } from 'react'
import type { Observation, ObservationZone, Vertebra } from '@/domain/schema/observation'
import type { Pathology } from '@/domain/schema/pathology'
import type { Bone } from '@/anatomy/types'
import Label from '@/components/ui/Label'
import Textarea from '@/components/ui/Textarea'
import Badge from '@/components/ui/Badge'
import PathologyPicker from './PathologyPicker'
import FreeTextPathologyInput from './FreeTextPathologyInput'
import SeveritySelector from './SeveritySelector'
export interface ObservationEditorProps {
observation: Observation
bones: Map<string, Bone>
speciesId: string
pathologyPool: Pathology[]
onChange: (next: Observation) => void
onOpenVertebraPicker: (zoneIndex: number) => void
onRemoveZone: (zoneIndex: number) => void
}
function describeZone(z: ObservationZone, bones: Map<string, Bone>): string {
const b = bones.get(z.boneId)
const label = b?.fr ?? z.boneId
if (z.vertebrae?.length) {
const vs = z.vertebrae.map((v: Vertebra) => `${v.region}${v.index}`).join(', ')
return `${label} (${vs})`
}
return label
}
export default function ObservationEditor({
observation,
bones,
speciesId,
pathologyPool,
onChange,
onOpenVertebraPicker,
onRemoveZone,
}: ObservationEditorProps) {
const zoneBoneIds = useMemo(
() => observation.zones.map((z) => z.boneId),
[observation.zones],
)
return (
<div className="space-y-6">
<section>
<Label>Zones sélectionnées</Label>
{observation.zones.length === 0 ? (
<p className="text-sm text-[var(--color-ink-muted)]">
Cliquez sur les zones du schéma pour les ajouter à cette observation.
</p>
) : (
<ul className="flex flex-wrap gap-2">
{observation.zones.map((z, i) => {
const b = bones.get(z.boneId)
const isSpine = b?.category === 'spine-zone'
return (
<li key={`${z.boneId}-${i}`}>
<Badge tone="accent" className="gap-2">
{describeZone(z, bones)}
{isSpine && (
<button
type="button"
onClick={() => onOpenVertebraPicker(i)}
className="underline text-xs text-[var(--color-accent-strong)]"
>
Préciser…
</button>
)}
<button
type="button"
aria-label={`Retirer ${b?.fr ?? z.boneId}`}
onClick={() => onRemoveZone(i)}
className="ml-1 text-[var(--color-accent-strong)]"
>
✕
</button>
</Badge>
</li>
)
})}
</ul>
)}
</section>
<section>
<Label>Pathologies (référence)</Label>
<PathologyPicker
pool={pathologyPool}
speciesId={speciesId}
boneIds={zoneBoneIds}
selected={observation.pathologyIds}
onChange={(ids) => onChange({ ...observation, pathologyIds: ids })}
/>
</section>
<section>
<Label>Pathologies (texte libre)</Label>
<FreeTextPathologyInput
items={observation.freeTextPathologies}
onChange={(items) => onChange({ ...observation, freeTextPathologies: items })}
/>
</section>
<section>
<Label>Sévérité</Label>
<SeveritySelector
value={observation.severity}
onChange={(s) => onChange({ ...observation, severity: s })}
/>
</section>
<section>
<Label htmlFor="obs-comment">Commentaire</Label>
<Textarea
id="obs-comment"
value={observation.comment}
onChange={(e) => onChange({ ...observation, comment: e.target.value })}
placeholder="Notes cliniques détaillées…"
/>
</section>
</div>
)
}