fix(anatomy,editor): detail-popup clicks + spine zones open VertebraPicker via data-anno-special
Three coupled bugs in zone interaction: 1. Clicks inside the head detail popup were ignored — EditorRoute looked up the clicked id in the main-SVG bones map only, so detail-only ids (point-mpbykomv et al.) returned undefined. 2. Spine zones did not open VertebraPicker on click; the picker was only reachable via the per-zone "Vertèbres…" button. 3. The new SVG hint data-anno-special="vertebral-precision" was present in Horse.svg but unread by the parser/UI. Parser now reads data-anno-special into Bone.special. EditorRoute parses the detail SVG on open and falls back to detailBones for id lookups. When bone.special === 'vertebral-precision', clicking adds the zone (if absent) and opens VertebraPicker for that zone index; toggle-off via main click is disabled for these zones (use ✕). The "Vertèbres…" button in ObservationCard is now shown only on zones that support it. Convention doc updated. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
21b678c3d5
commit
b9da4fa04a
7 files changed
+86
-22
No files matched your search
@@ -31,6 +31,7 @@ export default function EditorRoute() {
|
||||
const setNextAppointment = useReportStore((s) => s.setNextAppointment)
|
||||
|
||||
const [bones, setBones] = useState<Map<string, Bone>>(new Map())
|
||||
const [detailBones, setDetailBones] = useState<Map<string, Bone>>(new Map())
|
||||
const [pathologies, setPathologies] = useState<Pathology[]>([])
|
||||
const [detail, setDetail] = useState<{
|
||||
id: string
|
||||
@@ -55,6 +56,21 @@ export default function EditorRoute() {
|
||||
species.pathologies().then((m) => setPathologies(m.default))
|
||||
}, [species])
|
||||
|
||||
useEffect(() => {
|
||||
if (!detail) {
|
||||
setDetailBones(new Map())
|
||||
return
|
||||
}
|
||||
let cancelled = false
|
||||
loadSvg(detail.src).then((root) => {
|
||||
if (cancelled) return
|
||||
setDetailBones(parseSvgBones(root))
|
||||
})
|
||||
return () => {
|
||||
cancelled = true
|
||||
}
|
||||
}, [detail])
|
||||
|
||||
const activeObs =
|
||||
activeIndex >= 0 ? report?.observations[activeIndex] : undefined
|
||||
|
||||
@@ -82,7 +98,7 @@ export default function EditorRoute() {
|
||||
|
||||
function onZoneClick(boneId: string, detailSourceId?: string) {
|
||||
if (!report) return
|
||||
const bone = bones.get(boneId)
|
||||
const bone = bones.get(boneId) ?? detailBones.get(boneId)
|
||||
if (!bone) return
|
||||
|
||||
if (bone.opensDetail && species?.details[bone.opensDetail]) {
|
||||
@@ -105,18 +121,35 @@ export default function EditorRoute() {
|
||||
return
|
||||
}
|
||||
|
||||
const matches = (z: ObservationZone) =>
|
||||
z.boneId === boneId && z.detailSourceId === detailSourceId
|
||||
const existingIndex = activeObs.zones.findIndex(matches)
|
||||
|
||||
if (bone.special === 'vertebral-precision') {
|
||||
// Spine-zone behavior: always open VertebraPicker on click. Add the
|
||||
// zone if missing; never toggle it off here (use the ✕ button).
|
||||
let targetIndex = existingIndex
|
||||
if (existingIndex < 0) {
|
||||
const newZone: ObservationZone = {
|
||||
boneId,
|
||||
...(detailSourceId ? { detailSourceId } : {}),
|
||||
}
|
||||
const nextZones = [...activeObs.zones, newZone]
|
||||
targetIndex = nextZones.length - 1
|
||||
updateObservation(activeIndex, { ...activeObs, zones: nextZones })
|
||||
}
|
||||
setVertebraTarget(targetIndex)
|
||||
return
|
||||
}
|
||||
|
||||
const newZone: ObservationZone = {
|
||||
boneId,
|
||||
...(detailSourceId ? { detailSourceId } : {}),
|
||||
}
|
||||
const exists = activeObs.zones.some(
|
||||
(z) => z.boneId === boneId && z.detailSourceId === detailSourceId,
|
||||
)
|
||||
const nextZones = exists
|
||||
? activeObs.zones.filter(
|
||||
(z) => !(z.boneId === boneId && z.detailSourceId === detailSourceId),
|
||||
)
|
||||
: [...activeObs.zones, newZone]
|
||||
const nextZones =
|
||||
existingIndex >= 0
|
||||
? activeObs.zones.filter((_, k) => k !== existingIndex)
|
||||
: [...activeObs.zones, newZone]
|
||||
updateObservation(activeIndex, { ...activeObs, zones: nextZones })
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user