fix(app): editor route split into dialogs and pickers components, canvas without lint suppression, findings picker coverage restored; golden test pins every generated draft file; stale doc lines
This commit is contained in:
1 parent
0476276a8f
commit
09d8b01a54
11 files changed
+374
-161
No files matched your search
@@ -248,7 +248,7 @@ SVG interaction
|
|||||||
→ toggle / remove_both_sides → updateObservation() in store
|
→ toggle / remove_both_sides → updateObservation() in store
|
||||||
|
|
||||||
PDF export
|
PDF export
|
||||||
→ exportReportToPdf(report, { locale })
|
→ exportReportToPdf(report, sheet, { locale })
|
||||||
→ pdf-lib PDFDocument
|
→ pdf-lib PDFDocument
|
||||||
→ embedFonts (Helvetica body + TimesRoman heading — WinAnsi StandardFonts; TTF Inter/Fraunces planned)
|
→ embedFonts (Helvetica body + TimesRoman heading — WinAnsi StandardFonts; TTF Inter/Fraunces planned)
|
||||||
→ for each observation: addObservationPage (rasterize SVG → PNG)
|
→ for each observation: addObservationPage (rasterize SVG → PNG)
|
||||||
@@ -410,7 +410,7 @@ Database (Supabase)
|
|||||||
## Workflow expectations
|
## Workflow expectations
|
||||||
|
|
||||||
- Run `pnpm typecheck && pnpm test:run` before every commit.
|
- Run `pnpm typecheck && pnpm test:run` before every commit.
|
||||||
- Domain schema changes (domain/schema/*.ts) require updating all callers + bumping version if breaking.
|
- Domain schema changes (`packages/domain/src/report/*.ts`) require updating all callers + bumping version if breaking.
|
||||||
- Annotation rendering changes require updating docs/ANNOTATION-RENDERING.md first.
|
- Annotation rendering changes require updating docs/ANNOTATION-RENDERING.md first.
|
||||||
- Never modify the legacy sources under `supabase/seed/anatomical-sheets/equine/legacy-sources/` — they are the
|
- Never modify the legacy sources under `supabase/seed/anatomical-sheets/equine/legacy-sources/` — they are the
|
||||||
importer's input (the user's historical files).
|
importer's input (the user's historical files).
|
||||||
|
|||||||
@@ -1,37 +1,28 @@
|
|||||||
import { useCallback, useEffect, useMemo, useState } from 'react'
|
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||||
import { useNavigate } from 'react-router-dom'
|
import { useNavigate } from 'react-router-dom'
|
||||||
import type {
|
|
||||||
Animal,
|
|
||||||
LateralSide,
|
|
||||||
Owner,
|
|
||||||
Practitioner,
|
|
||||||
} from '@faunosteo/domain'
|
|
||||||
import AnatomyCanvas from '@/components/canvas/AnatomyCanvas'
|
import AnatomyCanvas from '@/components/canvas/AnatomyCanvas'
|
||||||
import DetailModal from '@/components/canvas/DetailModal'
|
import DetailModal from '@/components/canvas/DetailModal'
|
||||||
import ObservationList from '@/components/observation/ObservationList'
|
import ObservationList from '@/components/observation/ObservationList'
|
||||||
import VertebraPicker from '@/components/observation/VertebraPicker'
|
import ObservationPickers from '@/components/observation/ObservationPickers'
|
||||||
import LateralityPicker from '@/components/observation/LateralityPicker'
|
|
||||||
import ConclusionPanel from '@/components/report/ConclusionPanel'
|
import ConclusionPanel from '@/components/report/ConclusionPanel'
|
||||||
import ReportHeader from '@/components/report/ReportHeader'
|
import ReportHeader from '@/components/report/ReportHeader'
|
||||||
import PractitionerForm from '@/components/report/PractitionerForm'
|
import EditInfosDialog, {
|
||||||
import AnimalForm from '@/components/report/AnimalForm'
|
isIdentityComplete,
|
||||||
|
type Identity,
|
||||||
|
} from '@/components/report/EditInfosDialog'
|
||||||
|
import DisclaimerDialog from '@/components/report/DisclaimerDialog'
|
||||||
import Button from '@/components/ui/Button'
|
import Button from '@/components/ui/Button'
|
||||||
import Dialog from '@/components/ui/Dialog'
|
|
||||||
import { useReportStore } from '@/state/reportStore'
|
import { useReportStore } from '@/state/reportStore'
|
||||||
import { writeCachedPractitioner } from '@/state/practitionerCache'
|
import { writeCachedPractitioner } from '@/state/practitionerCache'
|
||||||
import { useLocaleStore } from '@/state/localeStore'
|
import { useLocaleStore } from '@/state/localeStore'
|
||||||
import { useSheet } from '@/sheets/useSheet'
|
import { useSheet } from '@/sheets/useSheet'
|
||||||
import { isObservable, pickLabel, type SheetIndex } from '@/services/sheetIndex'
|
import { pickLabel, type SheetIndex } from '@/services/sheetIndex'
|
||||||
import {
|
import {
|
||||||
addSides,
|
|
||||||
collectVertebrae,
|
|
||||||
decideZoneClick,
|
decideZoneClick,
|
||||||
ensureZone,
|
ensureZone,
|
||||||
refOf,
|
refOf,
|
||||||
removeAllSides,
|
removeAllSides,
|
||||||
removeZoneAt,
|
removeZoneAt,
|
||||||
sidesPresent,
|
|
||||||
syncVertebrae,
|
|
||||||
toggleZone,
|
toggleZone,
|
||||||
type ZoneRef,
|
type ZoneRef,
|
||||||
} from '@/services/zoneInteraction'
|
} from '@/services/zoneInteraction'
|
||||||
@@ -42,12 +33,6 @@ import { DEFAULT_SPECIES_ID } from './NewReportRoute'
|
|||||||
|
|
||||||
const DISCLAIMER_FLAG = 'osteo:disclaimer-shown'
|
const DISCLAIMER_FLAG = 'osteo:disclaimer-shown'
|
||||||
|
|
||||||
interface Identity {
|
|
||||||
practitioner: Practitioner
|
|
||||||
animal: Animal
|
|
||||||
owner: Owner
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Editor on the reference sheet: wires the canvas, the pickers and the store. */
|
/** Editor on the reference sheet: wires the canvas, the pickers and the store. */
|
||||||
export default function EditorRoute() {
|
export default function EditorRoute() {
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
@@ -148,14 +133,7 @@ export default function EditorRoute() {
|
|||||||
|
|
||||||
function saveEditInfos() {
|
function saveEditInfos() {
|
||||||
if (!editDraft) return
|
if (!editDraft) return
|
||||||
if (
|
if (!isIdentityComplete(editDraft)) return
|
||||||
![
|
|
||||||
editDraft.practitioner.name,
|
|
||||||
editDraft.animal.name,
|
|
||||||
editDraft.owner.name,
|
|
||||||
].every((v) => v.trim())
|
|
||||||
)
|
|
||||||
return
|
|
||||||
store.setPractitioner(editDraft.practitioner)
|
store.setPractitioner(editDraft.practitioner)
|
||||||
store.setAnimal(editDraft.animal)
|
store.setAnimal(editDraft.animal)
|
||||||
store.setOwner(editDraft.owner)
|
store.setOwner(editDraft.owner)
|
||||||
@@ -193,12 +171,6 @@ export default function EditorRoute() {
|
|||||||
}
|
}
|
||||||
if (sheet.status === 'none') return null
|
if (sheet.status === 'none') return null
|
||||||
const index = sheet.index
|
const index = sheet.index
|
||||||
const vertebraZone =
|
|
||||||
vertebraTarget !== null ? activeObs?.zones[vertebraTarget] : undefined
|
|
||||||
const vertebraAnnotation =
|
|
||||||
vertebraZone && index.annotation(vertebraZone.annotationId)
|
|
||||||
const lateralAnnotation =
|
|
||||||
lateralTarget && index.annotation(lateralTarget.annotationId)
|
|
||||||
const detailView = detailViewId ? index.view(detailViewId) : undefined
|
const detailView = detailViewId ? index.view(detailViewId) : undefined
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -283,116 +255,33 @@ export default function EditorRoute() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{editDraft && (
|
{editDraft && (
|
||||||
<Dialog
|
<EditInfosDialog
|
||||||
open
|
draft={editDraft}
|
||||||
onClose={() => setEditDraft(null)}
|
species={[
|
||||||
title={t('editor.edit_dialog_title')}
|
{ id: index.sheet.speciesId, name: index.sheet.document.name },
|
||||||
size="lg"
|
]}
|
||||||
>
|
onChange={setEditDraft}
|
||||||
<div className="space-y-8">
|
onCancel={() => setEditDraft(null)}
|
||||||
<PractitionerForm
|
onSave={saveEditInfos}
|
||||||
value={editDraft.practitioner}
|
/>
|
||||||
onChange={(next) =>
|
|
||||||
setEditDraft((d) => (d ? { ...d, practitioner: next } : d))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<AnimalForm
|
|
||||||
animal={editDraft.animal}
|
|
||||||
owner={editDraft.owner}
|
|
||||||
species={[
|
|
||||||
{ id: index.sheet.speciesId, name: index.sheet.document.name },
|
|
||||||
]}
|
|
||||||
onChangeAnimal={(next) =>
|
|
||||||
setEditDraft((d) => (d ? { ...d, animal: next } : d))
|
|
||||||
}
|
|
||||||
onChangeOwner={(next) =>
|
|
||||||
setEditDraft((d) => (d ? { ...d, owner: next } : d))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<div className="flex gap-3 justify-end pt-2 border-t border-[var(--color-border)]">
|
|
||||||
<Button variant="ghost" onClick={() => setEditDraft(null)}>
|
|
||||||
{t('common.cancel')}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
onClick={saveEditInfos}
|
|
||||||
disabled={
|
|
||||||
![
|
|
||||||
editDraft.practitioner.name,
|
|
||||||
editDraft.animal.name,
|
|
||||||
editDraft.owner.name,
|
|
||||||
].every((v) => v.trim())
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{t('common.save')}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Dialog>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{disclaimer && (
|
{disclaimer && (
|
||||||
<Dialog
|
<DisclaimerDialog
|
||||||
open
|
text={disclaimer}
|
||||||
onClose={acknowledgeDisclaimer}
|
onAcknowledge={acknowledgeDisclaimer}
|
||||||
title={t('editor.disclaimer_title')}
|
|
||||||
size="md"
|
|
||||||
>
|
|
||||||
<div className="space-y-4">
|
|
||||||
<p className="text-sm text-[var(--color-ink)]">{disclaimer}</p>
|
|
||||||
<div className="flex justify-end">
|
|
||||||
<Button onClick={acknowledgeDisclaimer}>
|
|
||||||
{t('common.understood')}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Dialog>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{vertebraTarget !== null &&
|
|
||||||
activeObs &&
|
|
||||||
vertebraZone &&
|
|
||||||
isObservable(vertebraAnnotation) && (
|
|
||||||
<VertebraPicker
|
|
||||||
open
|
|
||||||
onClose={() => setVertebraTarget(null)}
|
|
||||||
onConfirm={(vertebrae) => {
|
|
||||||
const fresh =
|
|
||||||
useReportStore.getState().report?.observations[activeIndex]
|
|
||||||
if (fresh) {
|
|
||||||
store.updateObservation(
|
|
||||||
activeIndex,
|
|
||||||
syncVertebrae(fresh, vertebrae, index, vertebraZone.viewId),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
setVertebraTarget(null)
|
|
||||||
}}
|
|
||||||
initial={collectVertebrae(activeObs, index, vertebraTarget)}
|
|
||||||
regions={index.regions()}
|
|
||||||
title={`${t('vertebra.title_prefix')}${pickLabel(vertebraAnnotation.name, locale)}`}
|
|
||||||
initialRegion={
|
|
||||||
vertebraAnnotation.vertebral_region_code ?? undefined
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{lateralTarget && activeObs && lateralAnnotation && (
|
|
||||||
<LateralityPicker
|
|
||||||
open
|
|
||||||
onClose={() => setLateralTarget(null)}
|
|
||||||
title={pickLabel(index.name(lateralAnnotation), locale)}
|
|
||||||
existingSides={sidesPresent(activeObs, lateralTarget)}
|
|
||||||
onSelect={(sides: LateralSide[]) => {
|
|
||||||
const fresh =
|
|
||||||
useReportStore.getState().report?.observations[activeIndex]
|
|
||||||
if (fresh)
|
|
||||||
store.updateObservation(
|
|
||||||
activeIndex,
|
|
||||||
addSides(fresh, lateralAnnotation, sides),
|
|
||||||
)
|
|
||||||
setLateralTarget(null)
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<ObservationPickers
|
||||||
|
sheet={index}
|
||||||
|
activeIndex={activeIndex}
|
||||||
|
activeObs={activeObs}
|
||||||
|
vertebraTarget={vertebraTarget}
|
||||||
|
lateralTarget={lateralTarget}
|
||||||
|
onCloseVertebra={() => setVertebraTarget(null)}
|
||||||
|
onCloseLateral={() => setLateralTarget(null)}
|
||||||
|
/>
|
||||||
</main>
|
</main>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useCallback, useEffect, useRef } from 'react'
|
import { useCallback, useEffect, useLayoutEffect, useRef } from 'react'
|
||||||
import { buildViewSvg, type ViewStates } from '@/anatomy/drawing'
|
import { buildViewSvg, type ViewStates } from '@/anatomy/drawing'
|
||||||
import type { SheetIndex } from '@/services/sheetIndex'
|
import type { SheetIndex } from '@/services/sheetIndex'
|
||||||
import { useLocaleStore } from '@/state/localeStore'
|
import { useLocaleStore } from '@/state/localeStore'
|
||||||
@@ -35,13 +35,16 @@ export default function AnatomyCanvas({
|
|||||||
const svgRef = useRef<HTMLDivElement | null>(null)
|
const svgRef = useRef<HTMLDivElement | null>(null)
|
||||||
const tooltipRef = useRef<HTMLDivElement | null>(null)
|
const tooltipRef = useRef<HTMLDivElement | null>(null)
|
||||||
const locale = useLocaleStore((s) => s.locale)
|
const locale = useLocaleStore((s) => s.locale)
|
||||||
|
// Latest states for the build effect, which must only re-run on a view change.
|
||||||
|
const statesRef = useRef(states)
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
statesRef.current = states
|
||||||
|
}, [states])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const host = svgRef.current
|
const host = svgRef.current
|
||||||
if (!host) return
|
if (!host) return
|
||||||
host.replaceChildren(buildViewSvg(index, viewId, states))
|
host.replaceChildren(buildViewSvg(index, viewId, statesRef.current))
|
||||||
// States are applied by the effect below; the build only needs the view.
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, [index, viewId])
|
}, [index, viewId])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
import type { LateralSide, Observation } from '@faunosteo/domain'
|
||||||
|
import VertebraPicker from '@/components/observation/VertebraPicker'
|
||||||
|
import LateralityPicker from '@/components/observation/LateralityPicker'
|
||||||
|
import { useReportStore } from '@/state/reportStore'
|
||||||
|
import { useLocaleStore } from '@/state/localeStore'
|
||||||
|
import { isObservable, pickLabel, type SheetIndex } from '@/services/sheetIndex'
|
||||||
|
import {
|
||||||
|
addSides,
|
||||||
|
collectVertebrae,
|
||||||
|
sidesPresent,
|
||||||
|
syncVertebrae,
|
||||||
|
type ZoneRef,
|
||||||
|
} from '@/services/zoneInteraction'
|
||||||
|
import { useT } from '@/i18n/useT'
|
||||||
|
|
||||||
|
export interface ObservationPickersProps {
|
||||||
|
sheet: SheetIndex
|
||||||
|
activeIndex: number
|
||||||
|
activeObs: Observation | undefined
|
||||||
|
vertebraTarget: number | null
|
||||||
|
lateralTarget: ZoneRef | null
|
||||||
|
onCloseVertebra: () => void
|
||||||
|
onCloseLateral: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Vertebra and laterality pickers of the active observation. */
|
||||||
|
export default function ObservationPickers({
|
||||||
|
sheet,
|
||||||
|
activeIndex,
|
||||||
|
activeObs,
|
||||||
|
vertebraTarget,
|
||||||
|
lateralTarget,
|
||||||
|
onCloseVertebra,
|
||||||
|
onCloseLateral,
|
||||||
|
}: ObservationPickersProps) {
|
||||||
|
const t = useT()
|
||||||
|
const locale = useLocaleStore((s) => s.locale)
|
||||||
|
const updateObservation = useReportStore((s) => s.updateObservation)
|
||||||
|
const vertebraZone =
|
||||||
|
vertebraTarget !== null ? activeObs?.zones[vertebraTarget] : undefined
|
||||||
|
const vertebraAnnotation =
|
||||||
|
vertebraZone && sheet.annotation(vertebraZone.annotationId)
|
||||||
|
const lateralAnnotation =
|
||||||
|
lateralTarget && sheet.annotation(lateralTarget.annotationId)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{vertebraTarget !== null &&
|
||||||
|
activeObs &&
|
||||||
|
vertebraZone &&
|
||||||
|
isObservable(vertebraAnnotation) && (
|
||||||
|
<VertebraPicker
|
||||||
|
open
|
||||||
|
onClose={onCloseVertebra}
|
||||||
|
onConfirm={(vertebrae) => {
|
||||||
|
const fresh =
|
||||||
|
useReportStore.getState().report?.observations[activeIndex]
|
||||||
|
if (fresh) {
|
||||||
|
updateObservation(
|
||||||
|
activeIndex,
|
||||||
|
syncVertebrae(fresh, vertebrae, sheet, vertebraZone.viewId),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
onCloseVertebra()
|
||||||
|
}}
|
||||||
|
initial={collectVertebrae(activeObs, sheet, vertebraTarget)}
|
||||||
|
regions={sheet.regions()}
|
||||||
|
title={`${t('vertebra.title_prefix')}${pickLabel(vertebraAnnotation.name, locale)}`}
|
||||||
|
initialRegion={
|
||||||
|
vertebraAnnotation.vertebral_region_code ?? undefined
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{lateralTarget && activeObs && lateralAnnotation && (
|
||||||
|
<LateralityPicker
|
||||||
|
open
|
||||||
|
onClose={onCloseLateral}
|
||||||
|
title={pickLabel(sheet.name(lateralAnnotation), locale)}
|
||||||
|
existingSides={sidesPresent(activeObs, lateralTarget)}
|
||||||
|
onSelect={(sides: LateralSide[]) => {
|
||||||
|
const fresh =
|
||||||
|
useReportStore.getState().report?.observations[activeIndex]
|
||||||
|
if (fresh)
|
||||||
|
updateObservation(
|
||||||
|
activeIndex,
|
||||||
|
addSides(fresh, lateralAnnotation, sides),
|
||||||
|
)
|
||||||
|
onCloseLateral()
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import Button from '@/components/ui/Button'
|
||||||
|
import Dialog from '@/components/ui/Dialog'
|
||||||
|
import { useT } from '@/i18n/useT'
|
||||||
|
|
||||||
|
export interface DisclaimerDialogProps {
|
||||||
|
text: string
|
||||||
|
onAcknowledge: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Scope disclaimer of the sheet, shown once per tab session. */
|
||||||
|
export default function DisclaimerDialog({
|
||||||
|
text,
|
||||||
|
onAcknowledge,
|
||||||
|
}: DisclaimerDialogProps) {
|
||||||
|
const t = useT()
|
||||||
|
return (
|
||||||
|
<Dialog
|
||||||
|
open
|
||||||
|
onClose={onAcknowledge}
|
||||||
|
title={t('editor.disclaimer_title')}
|
||||||
|
size="md"
|
||||||
|
>
|
||||||
|
<div className="space-y-4">
|
||||||
|
<p className="text-sm text-[var(--color-ink)]">{text}</p>
|
||||||
|
<div className="flex justify-end">
|
||||||
|
<Button onClick={onAcknowledge}>{t('common.understood')}</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Dialog>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
import type { ComponentProps } from 'react'
|
||||||
|
import type { Animal, Owner, Practitioner } from '@faunosteo/domain'
|
||||||
|
import Button from '@/components/ui/Button'
|
||||||
|
import Dialog from '@/components/ui/Dialog'
|
||||||
|
import PractitionerForm from '@/components/report/PractitionerForm'
|
||||||
|
import AnimalForm from '@/components/report/AnimalForm'
|
||||||
|
import { useT } from '@/i18n/useT'
|
||||||
|
|
||||||
|
export interface Identity {
|
||||||
|
practitioner: Practitioner
|
||||||
|
animal: Animal
|
||||||
|
owner: Owner
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EditInfosDialogProps {
|
||||||
|
draft: Identity
|
||||||
|
species: ComponentProps<typeof AnimalForm>['species']
|
||||||
|
onChange: (next: Identity) => void
|
||||||
|
onCancel: () => void
|
||||||
|
onSave: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The three names are mandatory to save the identity block. */
|
||||||
|
export function isIdentityComplete(identity: Identity): boolean {
|
||||||
|
return [
|
||||||
|
identity.practitioner.name,
|
||||||
|
identity.animal.name,
|
||||||
|
identity.owner.name,
|
||||||
|
].every((v) => v.trim())
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Identity edit dialog of the editor: practitioner, animal and owner. */
|
||||||
|
export default function EditInfosDialog({
|
||||||
|
draft,
|
||||||
|
species,
|
||||||
|
onChange,
|
||||||
|
onCancel,
|
||||||
|
onSave,
|
||||||
|
}: EditInfosDialogProps) {
|
||||||
|
const t = useT()
|
||||||
|
return (
|
||||||
|
<Dialog
|
||||||
|
open
|
||||||
|
onClose={onCancel}
|
||||||
|
title={t('editor.edit_dialog_title')}
|
||||||
|
size="lg"
|
||||||
|
>
|
||||||
|
<div className="space-y-8">
|
||||||
|
<PractitionerForm
|
||||||
|
value={draft.practitioner}
|
||||||
|
onChange={(next) => onChange({ ...draft, practitioner: next })}
|
||||||
|
/>
|
||||||
|
<AnimalForm
|
||||||
|
animal={draft.animal}
|
||||||
|
owner={draft.owner}
|
||||||
|
species={species}
|
||||||
|
onChangeAnimal={(next) => onChange({ ...draft, animal: next })}
|
||||||
|
onChangeOwner={(next) => onChange({ ...draft, owner: next })}
|
||||||
|
/>
|
||||||
|
<div className="flex gap-3 justify-end pt-2 border-t border-[var(--color-border)]">
|
||||||
|
<Button variant="ghost" onClick={onCancel}>
|
||||||
|
{t('common.cancel')}
|
||||||
|
</Button>
|
||||||
|
<Button onClick={onSave} disabled={!isIdentityComplete(draft)}>
|
||||||
|
{t('common.save')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Dialog>
|
||||||
|
)
|
||||||
|
}
|
||||||
Vendored
+1
-1
@@ -5,7 +5,7 @@ the Report v2 document as the current application produces it.
|
|||||||
|
|
||||||
| File | Content |
|
| File | Content |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `report-v2.full.json` | One report exercising every zone kind the editor can produce: plain hinge point, bilateral joint with both sides, spine zone with vertebrae, detail-popup zone, catalog findings (with and without vet referral and side), free text, severity, comment, conclusion, recommendations, dated next appointment. `boneId` values are the real `data-anno-id` of `public/species/equine/*.svg`; `zoneId`/`path` values exist in `pathologies.json`. |
|
| `report-v2.full.json` | One report exercising every zone kind the editor can produce: plain hinge point, bilateral joint with both sides, spine zone with vertebrae, detail-popup zone, catalog findings (with and without vet referral and side), free text, severity, comment, conclusion, recommendations, dated next appointment. `boneId` values are the real `data-anno-id` of the legacy `Horse.svg` / `Horse_head.svg` now kept under `supabase/seed/anatomical-sheets/equine/legacy-sources/`; `zoneId`/`path` values exist in `pathologies.json`. |
|
||||||
| `report-v2.minimal.json` | Smallest valid v2 report (no observations). |
|
| `report-v2.minimal.json` | Smallest valid v2 report (no observations). |
|
||||||
| `report-v2.full.pdf`, `report-v2.minimal.pdf` | The two reports exported by the v2 pipeline (commit 199e328, Step 5.0, rasteriser stubbed to a 1×1 PNG, no logos): the archive-like PDFs the v3 importer must read and migrate. Synthetic data only. |
|
| `report-v2.full.pdf`, `report-v2.minimal.pdf` | The two reports exported by the v2 pipeline (commit 199e328, Step 5.0, rasteriser stubbed to a 1×1 PNG, no logos): the archive-like PDFs the v3 importer must read and migrate. Synthetic data only. |
|
||||||
|
|
||||||
|
|||||||
@@ -109,4 +109,116 @@ describe('FindingsTreePicker on a sheet finding zone', () => {
|
|||||||
}),
|
}),
|
||||||
).toBeInTheDocument()
|
).toBeInTheDocument()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('flags a vet-referral leaf and omits the key on other leaves', async () => {
|
||||||
|
const user = userEvent.setup()
|
||||||
|
const onChange = vi.fn()
|
||||||
|
render(
|
||||||
|
<FindingsTreePicker
|
||||||
|
zone={sheet.findingZone('hip')!}
|
||||||
|
selected={[]}
|
||||||
|
onChange={onChange}
|
||||||
|
/>,
|
||||||
|
)
|
||||||
|
await user.click(
|
||||||
|
screen.getByRole('button', {
|
||||||
|
name: 'Ouvrir Dysfonctions ostéopathiques',
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
await user.click(
|
||||||
|
screen.getByRole('button', {
|
||||||
|
name: 'Ouvrir Restrictions de mobilité articulaire',
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
await user.click(
|
||||||
|
screen.getByRole('checkbox', { name: 'Hypermobilité / laxité perçue' }),
|
||||||
|
)
|
||||||
|
expect(onChange.mock.calls[0]![0][0].requiresVetReferral).toBe(true)
|
||||||
|
onChange.mockClear()
|
||||||
|
await user.click(
|
||||||
|
screen.getByRole('checkbox', { name: 'Hypomobilité globale' }),
|
||||||
|
)
|
||||||
|
expect(onChange.mock.calls[0]![0][0]).not.toHaveProperty(
|
||||||
|
'requiresVetReferral',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('count badges and scoping', () => {
|
||||||
|
const finding = (
|
||||||
|
path: string[],
|
||||||
|
extra: Partial<Finding> = {},
|
||||||
|
): Finding => ({
|
||||||
|
findingZoneId: 'hip',
|
||||||
|
path,
|
||||||
|
labelFrSnapshot: 'x',
|
||||||
|
labelEnSnapshot: 'x',
|
||||||
|
side: 'left',
|
||||||
|
...extra,
|
||||||
|
})
|
||||||
|
const base = [
|
||||||
|
finding(['hip-dysfunctions', 'articular', 'hypomobility']),
|
||||||
|
finding(['hip-dysfunctions', 'articular', 'hypermobility']),
|
||||||
|
finding(['hip-dysfunctions', 'muscular', 'trigger-points']),
|
||||||
|
]
|
||||||
|
|
||||||
|
function renderPicker(selected: Finding[]) {
|
||||||
|
render(
|
||||||
|
<FindingsTreePicker
|
||||||
|
zone={sheet.findingZone('hip')!}
|
||||||
|
side="left"
|
||||||
|
selected={selected}
|
||||||
|
onChange={vi.fn()}
|
||||||
|
/>,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
it('counts selected findings per level, none on a clean sibling', async () => {
|
||||||
|
const user = userEvent.setup()
|
||||||
|
renderPicker(base)
|
||||||
|
expect(
|
||||||
|
screen.getByLabelText('3 constats sélectionnés'),
|
||||||
|
).toBeInTheDocument()
|
||||||
|
expect(screen.getAllByLabelText(/constats? sélectionnés?$/)).toHaveLength(
|
||||||
|
1,
|
||||||
|
)
|
||||||
|
await user.click(
|
||||||
|
screen.getByRole('button', {
|
||||||
|
name: 'Ouvrir Dysfonctions ostéopathiques',
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
expect(
|
||||||
|
screen.getByLabelText('2 constats sélectionnés'),
|
||||||
|
).toBeInTheDocument()
|
||||||
|
expect(screen.getByLabelText('1 constat sélectionné')).toBeInTheDocument()
|
||||||
|
expect(screen.getAllByLabelText(/constats? sélectionnés?$/)).toHaveLength(
|
||||||
|
2,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('ignores findings of another zone or another side', async () => {
|
||||||
|
const user = userEvent.setup()
|
||||||
|
renderPicker([
|
||||||
|
finding(['hip-dysfunctions', 'articular', 'hypomobility'], {
|
||||||
|
findingZoneId: 'stifle',
|
||||||
|
}),
|
||||||
|
finding(['hip-dysfunctions', 'articular', 'hypomobility'], {
|
||||||
|
side: 'right',
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
expect(screen.queryByLabelText(/sélectionnés?$/)).toBeNull()
|
||||||
|
await user.click(
|
||||||
|
screen.getByRole('button', {
|
||||||
|
name: 'Ouvrir Dysfonctions ostéopathiques',
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
await user.click(
|
||||||
|
screen.getByRole('button', {
|
||||||
|
name: 'Ouvrir Restrictions de mobilité articulaire',
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
expect(
|
||||||
|
screen.getByRole('checkbox', { name: 'Hypomobilité globale' }),
|
||||||
|
).not.toBeChecked()
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
@@ -424,8 +424,9 @@ Rules of the import:
|
|||||||
`private.insert_sheet_draft` (audited with a null actor) and never calls
|
`private.insert_sheet_draft` (audited with a null actor) and never calls
|
||||||
`publish_sheet_version`; only a platform admin can publish it, after the
|
`publish_sheet_version`; only a platform admin can publish it, after the
|
||||||
business review of `REVIEW-REPORT.md` (pgTAP 007 pins both);
|
business review of `REVIEW-REPORT.md` (pgTAP 007 pins both);
|
||||||
- the source files under `apps/app/public/species/equine/` stay untouched
|
- the source files live under
|
||||||
and keep serving the current application.
|
`supabase/seed/anatomical-sheets/equine/legacy-sources/`, are never edited,
|
||||||
|
and the application no longer reads them (it bundles the draft).
|
||||||
|
|
||||||
Storage: bucket `anatomical-sheet-assets` (private, SVG only, 20 MiB cap),
|
Storage: bucket `anatomical-sheet-assets` (private, SVG only, 20 MiB cap),
|
||||||
objects `<sha256>.svg`, read policy `anatomical_sheet_assets_read` through
|
objects `<sha256>.svg`, read policy `anatomical_sheet_assets_read` through
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ Package-scoped: `pnpm --filter @faunosteo/app <script>`.
|
|||||||
|
|
||||||
1. From a clean clone, Node 24 active: `pnpm install` completes with no
|
1. From a clean clone, Node 24 active: `pnpm install` completes with no
|
||||||
"Ignored build scripts" warning.
|
"Ignored build scripts" warning.
|
||||||
2. `pnpm typecheck`, `pnpm test:run` (271 tests), `pnpm lint`, `pnpm build`
|
2. `pnpm typecheck`, `pnpm test:run` (310 tests), `pnpm lint`, `pnpm build`
|
||||||
all exit 0; `apps/app/dist/` contains `index.html`, `env.js`,
|
all exit 0; `apps/app/dist/` contains `index.html`, `env.js`,
|
||||||
`favicon`, logos (anatomy assets are bundled from the sheet seed, Step 5).
|
`favicon`, logos (anatomy assets are bundled from the sheet seed, Step 5).
|
||||||
3. `pnpm dev`, then in the browser: `/` (home), `/new` (form, species defaults
|
3. `pnpm dev`, then in the browser: `/` (home), `/new` (form, species defaults
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { readFile } from 'node:fs/promises'
|
import { readdir, readFile } from 'node:fs/promises'
|
||||||
import { join } from 'node:path'
|
import { join } from 'node:path'
|
||||||
import {
|
import {
|
||||||
DRAFT_SEED_SQL_FILE,
|
|
||||||
EQUINE_DRAFT_DIR,
|
EQUINE_DRAFT_DIR,
|
||||||
EQUINE_LEGACY_IMPORT_DIR,
|
EQUINE_LEGACY_IMPORT_DIR,
|
||||||
EQUINE_SOURCE_PATHS,
|
EQUINE_SOURCE_PATHS,
|
||||||
@@ -19,6 +18,14 @@ let legacy: Record<string, string>
|
|||||||
let draftFiles: Record<string, string>
|
let draftFiles: Record<string, string>
|
||||||
let draft: DraftResult
|
let draft: DraftResult
|
||||||
|
|
||||||
|
/** Recursive file list, relative to `dir`, with forward slashes. */
|
||||||
|
async function listFiles(dir: string): Promise<string[]> {
|
||||||
|
const entries = await readdir(dir, { recursive: true, withFileTypes: true })
|
||||||
|
return entries
|
||||||
|
.filter((entry) => entry.isFile())
|
||||||
|
.map((entry) => join(entry.parentPath, entry.name).slice(dir.length + 1))
|
||||||
|
}
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const run = await runDraft()
|
const run = await runDraft()
|
||||||
draft = run.draft
|
draft = run.draft
|
||||||
@@ -56,14 +63,18 @@ describe('committed legacy-import folder (golden)', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('committed draft folder (golden)', () => {
|
describe('committed draft folder (golden)', () => {
|
||||||
it.each([
|
it('equals a fresh run for every produced file (rerun pnpm import:equine)', async () => {
|
||||||
'document.json',
|
for (const [file, content] of Object.entries(draftFiles)) {
|
||||||
'assets.json',
|
expect(await readFile(join(draftDir, file), 'utf8'), file).toBe(content)
|
||||||
'CHANGELOG.md',
|
}
|
||||||
'REVIEW-REPORT.md',
|
})
|
||||||
DRAFT_SEED_SQL_FILE,
|
|
||||||
])('%s equals a fresh run (rerun pnpm import:equine)', async (file) => {
|
it('holds no file the run does not produce', async () => {
|
||||||
expect(await readFile(join(draftDir, file), 'utf8')).toBe(draftFiles[file])
|
const expected = [
|
||||||
|
...Object.keys(draftFiles),
|
||||||
|
...draft.assets.map((asset) => `assets/${asset.file}`),
|
||||||
|
]
|
||||||
|
expect((await listFiles(draftDir)).sort()).toEqual(expected.sort())
|
||||||
})
|
})
|
||||||
|
|
||||||
it('holds the cleaned drawing with the recorded sha256', async () => {
|
it('holds the cleaned drawing with the recorded sha256', async () => {
|
||||||
|
|||||||
Reference in new issue
Block a user