fix(editor): plurals, trimmed names, default tab, parent drawing confirmation

This commit is contained in:
bchanot committed 2026-11-04 19:40:43 +01:00
1 parent b42c6ae844
commit be4f468790
35 files changed
+385 -63

No files matched your search

@@ -478,3 +478,22 @@ about the local copy says it is temporary, limited to this tab and not saved on
|---|---|---|---|
| `editor.draft.status.copy_quota` | Copie locale temporaire impossible (onglet plein) : non enregistré sur le serveur | Temporary local copy impossible (tab full): not saved on the server | C25: header status said nothing about the server (was « …(stockage de l'onglet plein) ») |
| `editor.draft.status.copy_cap` | Copie locale temporaire impossible (deux autres copies dans cet onglet) : non enregistré sur le serveur | Temporary local copy impossible (two other copies in this tab): not saved on the server | C25 (was « …: deux autres brouillons ont déjà une copie dans cet onglet ») |
## Lot N1 (owner decisions 2026-11-04: plurals, parent illustration, category hint)
Plural keys use `<key>_one` / `<key>_other` (French 0 and 1 are singular). The base key is replaced by its two forms.
| Key | FR | EN | Old wording and why |
|---|---|---|---|
| `editor.annotations.tracing_one` / `_other` | {count} sommet posé. / {count} sommets posés. | {count} vertex placed. / {count} vertices placed. | Old « {count} sommet(s) posé(s). » / « {count} vertex(es) placed. »: agreement (C36) |
| `editor.annotations.geometry.vertices_one` / `_other` | {count} sommet / {count} sommets | {count} vertex / {count} vertices | Old single form « {count} sommets »: agreement (C36) |
| `editor.verification.errors_one` / `_other` | {count} erreur bloquante / {count} erreurs bloquantes | {count} blocking error / {count} blocking errors | Old L28 « {count} erreurs bloquantes »: its plural stays the ratified wording, the singular is new |
| `editor.verification.warnings_one` / `_other` | {count} avertissement / {count} avertissements | {count} warning / {count} warnings | Agreement (C36) |
| `editor.verification.to_confirm_one` / `_other` | {count} élément à confirmer / {count} éléments à confirmer | {count} item to confirm / {count} items to confirm | Agreement (C36) |
| `editor.verification.vet_referrals_one` / `_other` | {count} renvoi vers un vétérinaire / {count} renvois vers un vétérinaire | {count} veterinary referral / {count} veterinary referrals | Old « {count} renvoi(s) … » / « {count} veterinary referral(s) » |
| `editor.verification.uncited_one` / `_other` | {count} constat sans référence citée / {count} constats sans référence citée | {count} finding citing no reference / {count} findings citing no reference | Old « {count} constat(s) … » / « {count} finding(s) … » |
| `editor.verification.hint.errors_one` / `_other` | Corrigez l'erreur bloquante pour soumettre. / Corrigez les {count} erreurs bloquantes pour soumettre. | Fix the blocking error to submit. / Fix the {count} blocking errors to submit. | Old « Corrigez les {count} erreurs bloquantes pour soumettre. » / « Fix the {count} blocking errors to submit. » read « 1 erreurs » |
| `editor.views.drawing.use_parent_title` | Utiliser l'illustration de la vue parente ? | Use the parent view's drawing? | New: confirmation dialog (C39). The button label is unchanged |
| `editor.views.drawing.use_parent_body` | La vue affichera l'illustration de la vue parente à travers son recadrage. Son propre fichier d'illustration reste enregistré, et vous pouvez annuler ce changement (Annuler). Les annotations de la vue repassent « à confirmer ». | The view will show the parent view's drawing through its crop. Its own drawing file stays stored, and you can undo this change (Undo). The view's annotations go back to "to confirm". | New: names the effect (nothing deleted, undo, `reconfirm_redrawn_views`) |
| `editor.views.drawing.use_parent_confirm` / `_cancel` | Utiliser l'illustration parente / Annuler | Use the parent drawing / Cancel | New: dialog buttons |
| `editor.findings.new.category_in_zone` | Nouvelle catégorie dans la zone « {zone} » | New category in the zone « {zone} » | Replaces `editor.findings.new.category` (« Nouvelle catégorie de constats » / « New findings category »): the form names the zone the category lands in (C42) |
@@ -154,6 +154,12 @@ test.describe('editor drawings (A2)', () => {
await detail
.getByRole('button', { name: dict['editor.views.drawing.use_parent'] })
.click()
await page
.getByRole('dialog')
.getByRole('button', {
name: dict['editor.views.drawing.use_parent_confirm'],
})
.click()
await expect(
detail.getByText(dict['editor.views.drawing.inherited']),
).toBeVisible()
@@ -229,6 +229,8 @@ test.describe('editor geometry (adversarial)', () => {
requests.forbid(actor.account.email, actor.account.password)
const seed = await seedDraft(actor, { drawing: null, shape: standardShape })
await openEditor(page, dict, actor, seed.sheetId)
// No measurable view: the draft opens on Général (C40).
await selectTab(page, dict, 'annotations')
await expect(
page.getByText(dict['editor.annotations.unmeasured.hint'], {
exact: false,
+1 -1
View File
@@ -382,7 +382,7 @@ test.describe('editor journey (owner trial steps)', () => {
const verification = page.getByTestId('editor-tab-verification')
await expect(
verification.getByText(
dict['editor.verification.errors'].replace('{count}', '0'),
dict['editor.verification.errors_one'].replace('{count}', '0'),
),
).toBeVisible()
await expect(
@@ -31,16 +31,17 @@ import {
} from '@/editor/mode'
import { leaveGuardArmed, useEditorStore } from '@/editor/state/editorStore'
import { FocusConsumedContext, type FocusRequest } from '@/editor/focusRequest'
import type { EditorTabId, EditorTabProps } from '@/editor/tabs'
import {
initialTab,
type EditorTabId,
type EditorTabProps,
} from '@/editor/tabs'
import { useUndoShortcuts } from '@/editor/useUndoShortcuts'
import { useTabTier } from '@/editor/useViewport'
import { useAuthStore } from '@/state/authStore'
import { useT } from '@/i18n/useT'
import { SheetNotFound } from './AdminSheetRoute'
/** The tab the boards open on (04 and 05 both show the annotations). */
const FIRST_TAB: EditorTabId = 'annotations'
interface DraftEditorProps {
sheet: OfficialSheetAdmin
versionId: string
@@ -78,7 +79,7 @@ function DraftEditor({
}: DraftEditorProps) {
const t = useT()
const tier = useTabTier()
const [tab, setTab] = useState<EditorTabId>(FIRST_TAB)
const [chosen, setTab] = useState<EditorTabId | null>(null)
const [focus, setFocus] = useState<FocusRequest | undefined>()
const clearFocus = (serial: number) =>
setFocus((prev) => (prev?.serial === serial ? undefined : prev))
@@ -91,6 +92,13 @@ function DraftEditor({
const sessionVersion = useEditorStore((s) => s.versionId)
const failure = useEditorStore((s) => s.failure)
const recovery = useEditorStore((s) => s.recovery)
const previewState = useEditorStore((s) => s.previewState)
const opened = status === 'ready' && sessionVersion === versionId
// Chosen once per opened version: later edits never move the user off their tab.
if (chosen === null && opened && previewState) {
setTab(initialTab(previewState, tier))
}
const tab = chosen ?? 'annotations'
const mode = modeAfterSave(
editorMode({ hasRight, sheet, wide: tier === 'wide' }),
saveFailure,
@@ -60,6 +60,7 @@ function NameFields(props: Props) {
value={annotation.name?.[locale] ?? ''}
onCommit={rename(locale)}
readOnly={readOnly}
trim
error={edit.fieldError(locale)}
/>
))}
@@ -12,6 +12,7 @@ import {
type EditableGeometry,
type GroupFields,
} from '@/editor/annotations/geometryEdit'
import { usePlural } from '@/editor/plural'
import { useT } from '@/i18n/useT'
/** What applying the group answers: kept, or the words that say why not. */
@@ -208,7 +209,6 @@ function CircleRows(props: RowsProps<Extract<Fields, { type: 'circle' }>>) {
}
function PolygonRows(props: RowsProps<PolygonFields>) {
const t = useT()
const [selected, setSelected] = useState(0)
const { fields } = props
const change = (index: number, axis: 'x' | 'y', value: string) =>
@@ -218,11 +218,11 @@ function PolygonRows(props: RowsProps<PolygonFields>) {
i === index ? { ...row, [axis]: value } : row,
),
})
const count = String(fields.rows.length)
const plural = usePlural()
return (
<div className="space-y-2">
<p className="text-sm text-[var(--color-ink-muted)]">
{t('editor.annotations.geometry.vertices').replace('{count}', count)}
{plural('editor.annotations.geometry.vertices', fields.rows.length)}
</p>
{fields.rows.map((row, index) => (
<VertexRow
@@ -1,4 +1,5 @@
import Button from '@/components/ui/Button'
import { usePlural } from '@/editor/plural'
import { useT } from '@/i18n/useT'
/** While a zone or link is being traced: close (3 vertices at least) or drop it. */
@@ -12,10 +13,11 @@ export default function TracingBar({
onCancel: () => void
}) {
const t = useT()
const plural = usePlural()
return (
<div className="flex flex-wrap items-center gap-2">
<p className="text-sm text-[var(--color-ink-muted)]">
{t('editor.annotations.tracing').replace('{count}', String(count))}
{plural('editor.annotations.tracing', count)}
</p>
<Button type="button" size="sm" disabled={count < 3} onClick={onClose}>
{t('editor.annotations.trace_close')}
@@ -15,6 +15,8 @@ export interface TextFieldProps {
readOnly?: boolean
multiline?: boolean
maxLength?: number
/** Opt-in for names and simple labels: the committed value loses its edge spaces. */
trim?: boolean
hint?: string
/** The refusal phrased by the caller, shown next to the control. */
error?: string
@@ -46,6 +48,7 @@ function EditableText({
onCommit,
multiline,
maxLength,
trim,
hint,
error,
}: TextFieldProps) {
@@ -56,20 +59,23 @@ function EditableText({
setSeen(value)
setDraft(value)
}
const latest = useRef({ draft, value, onCommit })
const latest = useRef({ draft, value, onCommit, trim })
useEffect(() => {
latest.current = { draft, value, onCommit }
latest.current = { draft, value, onCommit, trim }
})
useEffect(
() => () => {
const pending = latest.current
if (pending.draft !== pending.value) pending.onCommit(pending.draft)
const next = pending.trim ? pending.draft.trim() : pending.draft
if (next !== pending.value) pending.onCommit(next)
},
[],
)
const commit = () => {
if (draft !== value) onCommit(draft)
const next = trim ? draft.trim() : draft
if (next !== draft) setDraft(next)
if (next !== value) onCommit(next)
}
const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
if (event.key === 'Enter' && !event.nativeEvent.isComposing) commit()
@@ -9,9 +9,10 @@ import DraftField from '@/components/editor/fields/DraftField'
import SelectField from '@/components/editor/fields/SelectField'
import type { FindingItem, FindingKind } from '@/editor/findings/tree'
import type { IdPrefix } from '@/editor/ids'
import { isBlank } from '@/editor/sheetDocument'
import { elementLabel, isBlank, useSheetDocument } from '@/editor/sheetDocument'
import { useEditCommand } from '@/editor/useEditCommand'
import { useT } from '@/i18n/useT'
import { useLocaleStore } from '@/state/localeStore'
export const CATEGORY_KINDS: readonly FindingCategoryKind[] = [
'dysfunction',
@@ -40,6 +41,7 @@ export default function FindingCreateForm({
onCancel: () => void
}) {
const t = useT()
const title = useFormTitle(pending)
const edit = useEditCommand()
const [fr, setFr] = useState('')
const [en, setEn] = useState('')
@@ -54,15 +56,13 @@ export default function FindingCreateForm({
let createdId = ''
const added = edit.runNew('form', PREFIX[pending.kind], (id) => {
createdId = id
return insertCommand(pending, id, { fr, en }, kind)
return insertCommand(pending, id, { fr: fr.trim(), en: en.trim() }, kind)
})
if (added) onCreated(createdId)
}
return (
<div className="space-y-2 rounded-lg border border-dashed border-[var(--color-border)] p-3">
<p className="text-sm font-medium">
{t(`editor.findings.new.${pending.kind}`)}
</p>
<p className="text-sm font-medium">{title}</p>
<div className="grid gap-3 md:grid-cols-2">
{pending.kind === 'category' && (
<SelectField
@@ -109,6 +109,22 @@ export default function FindingCreateForm({
)
}
/** A category lands at zone level, so its title names the zone, whatever is selected. */
function useFormTitle(pending: PendingFinding): string {
const t = useT()
const doc = useSheetDocument()
const locale = useLocaleStore((s) => s.locale)
if (pending.kind !== 'category' || !doc || !pending.parent) {
return t(`editor.findings.new.${pending.kind}`)
}
const zone = elementLabel(
doc,
{ kind: 'zone', id: pending.parent.zoneId },
locale,
)
return t('editor.findings.new.category_in_zone').replace('{zone}', zone)
}
const PREFIX: Record<FindingKind, IdPrefix> = {
zone: 'zone',
category: 'fcat',
@@ -92,6 +92,7 @@ function Names({
value={item.name[locale]}
onCommit={rename(locale)}
readOnly={readOnly}
trim
error={edit.fieldError(locale)}
/>
))}
@@ -48,6 +48,7 @@ export default function AttributionSection({
value={attribution.license ?? ''}
onCommit={(value) => send('license', { license: nullable(value) })}
readOnly={readOnly}
trim
error={edit.fieldError('license')}
/>
<TextField
@@ -78,7 +79,7 @@ function Authors({
const [draft, setDraft] = useState('')
const add = () => {
if (isBlank(draft)) return
if (onChange([...authors, draft])) setDraft('')
if (onChange([...authors, draft.trim()])) setDraft('')
}
return (
<div className="space-y-2">
@@ -91,6 +91,7 @@ function CategoryRow({
value={category.name[locale]}
onCommit={rename(locale)}
readOnly={readOnly}
trim
error={edit.fieldError(locale)}
/>
))}
@@ -133,7 +134,11 @@ function CategoryForm() {
op: 'insert',
element: {
kind: 'category',
value: { id, name: { fr, en }, color: nullable(color) },
value: {
id,
name: { fr: fr.trim(), en: en.trim() },
color: nullable(color),
},
},
}))
if (added) {
@@ -47,6 +47,7 @@ export default function TextsSection({
value={doc.name[locale]}
onCommit={rename(locale)}
readOnly={readOnly}
trim
error={edit.fieldError(`name-${locale}`)}
/>
))}
@@ -4,6 +4,7 @@ import type {
SheetReport,
StatusCounts,
} from '@faunosteo/core-wasm/types'
import { usePlural } from '@/editor/plural'
import { elementLabel } from '@/editor/sheetDocument'
import { DOCUMENT_BYTES_CAP, groupThousands } from '@/editor/verification'
import { useT } from '@/i18n/useT'
@@ -53,7 +54,7 @@ function GroupRow({ group, label }: { group: ReviewGroup; label: string }) {
export function Completeness({ report }: { report: SheetReport }) {
const t = useT()
const { statuses, vet_referrals, uncited } = report.completeness
const count = (key: string, n: number) => t(key).replace('{count}', String(n))
const count = usePlural()
return (
<section
aria-label={t('editor.verification.completeness')}
@@ -3,6 +3,7 @@ import FormField from '@/components/ui/FormField'
import Textarea from '@/components/ui/Textarea'
import { useEditorStore } from '@/editor/state/editorStore'
import { NOTE_MAX_LENGTH } from '@/editor/verification'
import { usePlural } from '@/editor/plural'
import { useT } from '@/i18n/useT'
import { useSubmission } from './useSubmission'
@@ -17,12 +18,10 @@ function useBlockingHint(
noteBlank: boolean,
): string | null {
const t = useT()
const plural = usePlural()
const unsaved = useEditorStore((s) => s.unsaved || s.staleBase)
if (errorCount > 0) {
return t('editor.verification.hint.errors').replace(
'{count}',
String(errorCount),
)
return plural('editor.verification.hint.errors', errorCount)
}
if (unsaved) return t('editor.verification.hint.unsaved')
return noteBlank ? t('editor.verification.hint.note') : null
@@ -1,4 +1,5 @@
import Badge from '@/components/ui/Badge'
import { usePlural } from '@/editor/plural'
import { useT } from '@/i18n/useT'
interface VerificationSummaryProps {
@@ -14,7 +15,7 @@ export default function VerificationSummary({
toConfirm,
}: VerificationSummaryProps) {
const t = useT()
const count = (key: string, n: number) => t(key).replace('{count}', String(n))
const count = usePlural()
return (
<div className="space-y-2">
<h2 className="text-base font-medium">
@@ -31,7 +31,7 @@ export default function RegionForm() {
kind: 'region',
value: {
code: form.code,
name: { fr: form.fr, en: form.en },
name: { fr: form.fr.trim(), en: form.en.trim() },
count,
count_range: range.range,
},
@@ -70,6 +70,7 @@ export default function RegionRow({
value={region.name[locale]}
onCommit={rename(locale)}
readOnly={readOnly}
trim
error={edit.fieldError(locale)}
/>
))}
@@ -41,7 +41,7 @@ export default function DetailViewForm({
value: {
kind: 'detail',
id,
name: { fr: form.fr, en: form.en },
name: { fr: form.fr.trim(), en: form.en.trim() },
svg_asset_id: null,
view_box: box.box,
parent_view_id: parent,
@@ -0,0 +1,35 @@
import Button from '@/components/ui/Button'
import Dialog from '@/components/ui/Dialog'
import { useT } from '@/i18n/useT'
export interface ParentDrawingDialogProps {
open: boolean
onConfirm: () => void
onCancel: () => void
}
/** Names what « Utiliser l'illustration de la vue parente » does before it commits. */
export default function ParentDrawingDialog({
open,
onConfirm,
onCancel,
}: ParentDrawingDialogProps) {
const t = useT()
return (
<Dialog
open={open}
onClose={onCancel}
title={t('editor.views.drawing.use_parent_title')}
description={t('editor.views.drawing.use_parent_body')}
>
<div className="mt-4 flex flex-wrap justify-end gap-2">
<Button type="button" variant="ghost" onClick={onCancel}>
{t('editor.views.drawing.use_parent_cancel')}
</Button>
<Button type="button" onClick={onConfirm}>
{t('editor.views.drawing.use_parent_confirm')}
</Button>
</div>
</Dialog>
)
}
@@ -1,4 +1,4 @@
import { useRef, type ChangeEvent } from 'react'
import { useRef, useState, type ChangeEvent } from 'react'
import type { SheetView } from '@faunosteo/core-wasm/types'
import ActionButton from '@/components/editor/fields/ActionButton'
import Notice from '@/components/ui/Notice'
@@ -16,6 +16,7 @@ import { useViewUpdate } from '@/editor/useViewUpdate'
import { useT } from '@/i18n/useT'
import { useLocaleStore } from '@/state/localeStore'
import CleaningDialog from './CleaningDialog'
import ParentDrawingDialog from './ParentDrawingDialog'
/**
* A view's drawing: its state, the hint when it is not usable, « Choisir une
@@ -92,6 +93,11 @@ function DrawingActions({
const t = useT()
const upload = useDrawingUpload(view.id)
const views = useViewUpdate()
const [asking, setAsking] = useState(false)
const usesParent = () => {
setAsking(false)
views.update('drawing', view.id, { svg_asset_id: null }, true)
}
return (
<>
<div className="flex flex-wrap items-center gap-2">
@@ -101,14 +107,17 @@ function DrawingActions({
readOnly={false}
variant="ghost"
size="sm"
onClick={() =>
views.update('drawing', view.id, { svg_asset_id: null }, true)
}
onClick={() => setAsking(true)}
>
{t('editor.views.drawing.use_parent')}
</ActionButton>
)}
</div>
<ParentDrawingDialog
open={asking}
onConfirm={usesParent}
onCancel={() => setAsking(false)}
/>
<UploadNotices upload={upload} />
{views.error('drawing') && (
<Notice tone="error">{views.error('drawing')}</Notice>
@@ -35,6 +35,7 @@ export default function ViewNames({
value={view.name[locale]}
onCommit={rename(locale)}
readOnly={readOnly}
trim
error={views.error(locale)}
/>
))}
+2 -2
View File
@@ -137,14 +137,14 @@ export function annotationOf(
return {
...common,
kind: 'detail_trigger',
name: named ? { fr: form.fr, en: form.en } : null,
name: named ? { fr: form.fr.trim(), en: form.en.trim() } : null,
opens_view_id: form.opensViewId,
}
}
return {
...common,
kind: pending.kind,
name: { fr: form.fr, en: form.en },
name: { fr: form.fr.trim(), en: form.en.trim() },
finding_zone_id: orNull(form.zoneId),
vertebral_region_code: orNull(form.regionCode),
}
+17
View File
@@ -0,0 +1,17 @@
import { useT } from '@/i18n/useT'
import { useLocaleStore } from '@/state/localeStore'
import type { Locale } from '@/i18n/types'
/** `<key>_one` or `<key>_other` by the locale's plural rule (fr: 0 and 1 are singular). */
export function pluralKey(locale: Locale, key: string, count: number): string {
const category = new Intl.PluralRules(locale).select(count)
return `${key}_${category === 'one' ? 'one' : 'other'}`
}
/** A count phrase: picks the plural form of `key` and fills `{count}`. */
export function usePlural(): (key: string, count: number) => string {
const t = useT()
const locale = useLocaleStore((s) => s.locale)
return (key, count) =>
t(pluralKey(locale, key, count)).replace('{count}', String(count))
}
+13 -1
View File
@@ -1,5 +1,6 @@
import type { ElementKey } from '@faunosteo/core-wasm/types'
import type { ElementKey, PreviewState } from '@faunosteo/core-wasm/types'
import type { FocusRequest } from './focusRequest'
import { unmeasuredViews } from './issues'
import type { TabTier } from './useViewport'
export const EDITOR_TABS = [
@@ -28,6 +29,17 @@ export function tabsFor(tier: TabTier): {
return { shown, more: EDITOR_TABS.filter((tab) => !shown.includes(tab)) }
}
/**
* The tab a version opens on: Annotations once a view can be annotated, Général while
* there is nothing to annotate yet. A tier that does not list Général keeps Annotations.
*/
export function initialTab(state: PreviewState, tier: TabTier): EditorTabId {
const unmeasured = unmeasuredViews(state)
const measurable = state.document.views.some((v) => !unmeasured.has(v.id))
const wanted = measurable ? 'annotations' : 'general'
return SHOWN[tier].includes(wanted) ? wanted : 'annotations'
}
/** Props of every tab body (Lots F-J fill them): read-only flag, tab jump, sheet reload. */
export interface EditorTabProps {
/** Not editable now: a mode that cannot save, or a recovery offer not answered yet. */
+21 -9
View File
@@ -1360,6 +1360,10 @@ export const en: Dict = {
'editor.views.drawing.choose': 'Choose a drawing',
'editor.views.drawing.file': 'Drawing file (SVG)',
'editor.views.drawing.use_parent': "Use the parent view's drawing",
'editor.views.drawing.use_parent_title': "Use the parent view's drawing?",
'editor.views.drawing.use_parent_body': "The view will show the parent view's drawing through its crop. Its own drawing file stays stored, and you can undo this change (Undo). The view's annotations go back to \"to confirm\".",
'editor.views.drawing.use_parent_confirm': "Use the parent drawing",
'editor.views.drawing.use_parent_cancel': 'Cancel',
'editor.views.crop.title': 'Crop',
'editor.views.crop.toggle': 'Edit the crop',
'editor.views.crop.min_x': 'Crop: minimum x',
@@ -1426,7 +1430,7 @@ export const en: Dict = {
'editor.findings.add_category': 'Add a category',
'editor.findings.add_node': 'Add a finding',
'editor.findings.new.zone': 'New findings zone',
'editor.findings.new.category': 'New findings category',
'editor.findings.new.category_in_zone': 'New category in the zone « {zone} »',
'editor.findings.new.node': 'New finding',
'editor.findings.kind': 'Category type',
'editor.findings.kind.dysfunction': 'Dysfunction',
@@ -1495,7 +1499,8 @@ export const en: Dict = {
'editor.annotations.selection': 'Selection: {kind} « {name} »',
'editor.annotations.select_hint': 'Select an annotation on the drawing or in the list to see its properties.',
'editor.annotations.properties': 'Annotation properties',
'editor.annotations.tracing': '{count} vertex(es) placed.',
'editor.annotations.tracing_one': '{count} vertex placed.',
'editor.annotations.tracing_other': '{count} vertices placed.',
'editor.annotations.trace_close': 'Close the tracing',
'editor.annotations.trace_cancel': 'Cancel the tracing',
'editor.annotations.replace_polygon': 'Replace with a polygon',
@@ -1508,7 +1513,8 @@ export const en: Dict = {
'editor.annotations.geometry.r': 'Radius',
'editor.annotations.geometry.vertex_x': 'x of vertex {n}',
'editor.annotations.geometry.vertex_y': 'y of vertex {n}',
'editor.annotations.geometry.vertices': '{count} vertices',
'editor.annotations.geometry.vertices_one': '{count} vertex',
'editor.annotations.geometry.vertices_other': '{count} vertices',
'editor.annotations.geometry.add_vertex': 'Add a vertex',
'editor.annotations.geometry.unapplied': 'Values not applied: the draft is unchanged.',
'editor.annotations.geometry.unapplied_tag': 'not applied',
@@ -1523,16 +1529,21 @@ export const en: Dict = {
'editor.findings.references_none': 'No reference cited.',
'editor.findings.reference_add': 'Cite a reference',
'editor.verification.title': 'Draft check',
'editor.verification.errors': '{count} blocking errors',
'editor.verification.warnings': '{count} warnings',
'editor.verification.to_confirm': '{count} items to confirm',
'editor.verification.errors_one': '{count} blocking error',
'editor.verification.errors_other': '{count} blocking errors',
'editor.verification.warnings_one': '{count} warning',
'editor.verification.warnings_other': '{count} warnings',
'editor.verification.to_confirm_one': '{count} item to confirm',
'editor.verification.to_confirm_other': '{count} items to confirm',
'editor.verification.none': 'No issues found',
'editor.verification.warnings_title': 'Warnings',
'editor.verification.goto': 'Go to {tab}',
'editor.verification.to_confirm_info': 'Some items are still to confirm: this does not prevent submission.',
'editor.verification.completeness': 'Completeness',
'editor.verification.vet_referrals': '{count} veterinary referral(s)',
'editor.verification.uncited': '{count} finding(s) citing no reference',
'editor.verification.vet_referrals_one': '{count} veterinary referral',
'editor.verification.vet_referrals_other': '{count} veterinary referrals',
'editor.verification.uncited_one': '{count} finding citing no reference',
'editor.verification.uncited_other': '{count} findings citing no reference',
'editor.verification.groups': 'Statuses per group',
'editor.verification.group_removed': 'removed',
'editor.verification.status.to_confirm': 'To confirm',
@@ -1554,7 +1565,8 @@ export const en: Dict = {
'editor.verification.note': 'Submission note (required)',
'editor.verification.submit_title': 'Submission',
'editor.verification.submit': 'Submit for review',
'editor.verification.hint.errors': 'Fix the {count} blocking errors to submit.',
'editor.verification.hint.errors_one': 'Fix the blocking error to submit.',
'editor.verification.hint.errors_other': 'Fix the {count} blocking errors to submit.',
'editor.verification.hint.unsaved': 'Save the draft before submitting it.',
'editor.verification.hint.note': 'Enter the submission note to submit.',
'editor.verification.issue.unknown': 'This item breaks a rule of the sheet. Fix the item shown.',
+21 -9
View File
@@ -1391,6 +1391,10 @@ export const fr: Dict = {
'editor.views.drawing.choose': 'Choisir une illustration',
'editor.views.drawing.file': "Fichier d'illustration (SVG)",
'editor.views.drawing.use_parent': "Utiliser l'illustration de la vue parente",
'editor.views.drawing.use_parent_title': "Utiliser l'illustration de la vue parente ?",
'editor.views.drawing.use_parent_body': "La vue affichera l'illustration de la vue parente à travers son recadrage. Son propre fichier d'illustration reste enregistré, et vous pouvez annuler ce changement (Annuler). Les annotations de la vue repassent « à confirmer ».",
'editor.views.drawing.use_parent_confirm': "Utiliser l'illustration parente",
'editor.views.drawing.use_parent_cancel': 'Annuler',
'editor.views.crop.title': 'Recadrage',
'editor.views.crop.toggle': 'Modifier le recadrage',
'editor.views.crop.min_x': 'Recadrage : x minimum',
@@ -1457,7 +1461,7 @@ export const fr: Dict = {
'editor.findings.add_category': 'Ajouter une catégorie',
'editor.findings.add_node': 'Ajouter un constat',
'editor.findings.new.zone': 'Nouvelle zone de constats',
'editor.findings.new.category': 'Nouvelle catégorie de constats',
'editor.findings.new.category_in_zone': 'Nouvelle catégorie dans la zone « {zone} »',
'editor.findings.new.node': 'Nouveau constat',
'editor.findings.kind': 'Type de catégorie',
'editor.findings.kind.dysfunction': 'Dysfonction',
@@ -1526,7 +1530,8 @@ export const fr: Dict = {
'editor.annotations.selection': 'Sélection : {kind} « {name} »',
'editor.annotations.select_hint': 'Sélectionnez une annotation sur le dessin ou dans la liste pour voir ses propriétés.',
'editor.annotations.properties': "Propriétés de l'annotation",
'editor.annotations.tracing': '{count} sommet(s) posé(s).',
'editor.annotations.tracing_one': '{count} sommet posé.',
'editor.annotations.tracing_other': '{count} sommets posés.',
'editor.annotations.trace_close': 'Fermer le tracé',
'editor.annotations.trace_cancel': 'Annuler le tracé',
'editor.annotations.replace_polygon': 'Remplacer par un polygone',
@@ -1539,7 +1544,8 @@ export const fr: Dict = {
'editor.annotations.geometry.r': 'Rayon',
'editor.annotations.geometry.vertex_x': 'x du sommet {n}',
'editor.annotations.geometry.vertex_y': 'y du sommet {n}',
'editor.annotations.geometry.vertices': '{count} sommets',
'editor.annotations.geometry.vertices_one': '{count} sommet',
'editor.annotations.geometry.vertices_other': '{count} sommets',
'editor.annotations.geometry.add_vertex': 'Ajouter un sommet',
'editor.annotations.geometry.unapplied': 'Valeurs non appliquées : le brouillon est inchangé.',
'editor.annotations.geometry.unapplied_tag': 'non appliqué',
@@ -1554,16 +1560,21 @@ export const fr: Dict = {
'editor.findings.references_none': 'Aucune référence citée.',
'editor.findings.reference_add': 'Citer une référence',
'editor.verification.title': 'Contrôle du brouillon',
'editor.verification.errors': '{count} erreurs bloquantes',
'editor.verification.warnings': '{count} avertissements',
'editor.verification.to_confirm': '{count} éléments à confirmer',
'editor.verification.errors_one': '{count} erreur bloquante',
'editor.verification.errors_other': '{count} erreurs bloquantes',
'editor.verification.warnings_one': '{count} avertissement',
'editor.verification.warnings_other': '{count} avertissements',
'editor.verification.to_confirm_one': '{count} élément à confirmer',
'editor.verification.to_confirm_other': '{count} éléments à confirmer',
'editor.verification.none': 'Aucun problème détecté',
'editor.verification.warnings_title': 'Avertissements',
'editor.verification.goto': 'Aller à {tab}',
'editor.verification.to_confirm_info': "Des éléments restent à confirmer : cela n'empêche pas la soumission.",
'editor.verification.completeness': 'Complétude',
'editor.verification.vet_referrals': '{count} renvoi(s) vers un vétérinaire',
'editor.verification.uncited': '{count} constat(s) sans référence citée',
'editor.verification.vet_referrals_one': '{count} renvoi vers un vétérinaire',
'editor.verification.vet_referrals_other': '{count} renvois vers un vétérinaire',
'editor.verification.uncited_one': '{count} constat sans référence citée',
'editor.verification.uncited_other': '{count} constats sans référence citée',
'editor.verification.groups': 'Statuts par groupe',
'editor.verification.group_removed': 'supprimé',
'editor.verification.status.to_confirm': 'À confirmer',
@@ -1585,7 +1596,8 @@ export const fr: Dict = {
'editor.verification.note': 'Note de soumission (obligatoire)',
'editor.verification.submit_title': 'Soumission',
'editor.verification.submit': 'Soumettre à la revue',
'editor.verification.hint.errors': 'Corrigez les {count} erreurs bloquantes pour soumettre.',
'editor.verification.hint.errors_one': "Corrigez l'erreur bloquante pour soumettre.",
'editor.verification.hint.errors_other': 'Corrigez les {count} erreurs bloquantes pour soumettre.',
'editor.verification.hint.unsaved': 'Enregistrez le brouillon avant de le soumettre.',
'editor.verification.hint.note': 'Saisissez la note de soumission pour soumettre.',
'editor.verification.issue.unknown': "Ce point ne respecte pas une règle de la fiche. Corrigez l'élément indiqué.",
@@ -577,11 +577,11 @@ describe('tracing a zone or a link', () => {
)
await userEvent.setup().click(screen.getByRole('button', { name: 'Zone' }))
clickAt(20, 20)
expect(screen.getByText('1 sommet(s) posé(s).')).toBeInTheDocument()
expect(screen.getByText('1 sommet posé.')).toBeInTheDocument()
fireEvent.keyDown(screen.getByTestId('annotation-canvas'), {
key: 'Escape',
})
expect(screen.queryByText('1 sommet(s) posé(s).')).toBeNull()
expect(screen.queryByText('1 sommet posé.')).toBeNull()
expect(annotations()).toHaveLength(0)
})
@@ -47,6 +47,42 @@ describe('TextField', () => {
expect(onCommit).toHaveBeenCalledWith('Chevalz')
})
it('trim commits a padded name without its edge spaces', async () => {
const user = userEvent.setup()
const onCommit = vi.fn()
render(
<TextField id="f" label="Nom" value="Cheval" onCommit={onCommit} trim />,
)
await user.type(screen.getByLabelText('Nom'), ' {Enter}')
expect(onCommit).not.toHaveBeenCalled()
await user.type(screen.getByLabelText('Nom'), 'x ')
await user.tab()
expect(onCommit).toHaveBeenCalledWith('Chevalx')
})
it('trim: a blank value commits as empty; unmount trims too', async () => {
const user = userEvent.setup()
const onCommit = vi.fn()
const view = render(
<TextField id="f" label="Nom" value="" onCommit={onCommit} trim />,
)
await user.type(screen.getByLabelText('Nom'), ' ')
await user.tab()
expect(onCommit).not.toHaveBeenCalled()
await user.type(screen.getByLabelText('Nom'), ' a ')
view.unmount()
expect(onCommit).toHaveBeenCalledWith('a')
})
it('without trim a padded description commits unchanged', async () => {
const user = userEvent.setup()
const onCommit = vi.fn()
render(<TextField id="f" label="Texte" value="" onCommit={onCommit} />)
await user.type(screen.getByLabelText('Texte'), ' a ')
await user.tab()
expect(onCommit).toHaveBeenCalledWith(' a ')
})
it('a new committed value replaces what was typed; the refusal shows next to the control', () => {
const view = render(
<TextField
@@ -276,6 +276,37 @@ describe('Constats tab', () => {
expect(doc().finding_zones[0].categories[1].children).toHaveLength(1)
})
it('names the zone a category lands in and appends it at zone level, a node selected', async () => {
await openReady({ text: treeText() })
const user = userEvent.setup()
render(<FindingsTab {...props} />)
items()[0].focus()
await user.keyboard('{ArrowDown}{ArrowRight}{ArrowRight}')
expect(items()[2]).toHaveAttribute('aria-selected', 'true')
await user.click(
screen.getByRole('button', { name: 'Ajouter une catégorie' }),
)
expect(
screen.getByText('Nouvelle catégorie dans la zone « Zone A »'),
).toBeInTheDocument()
await user.type(
screen.getByLabelText('Nom (FR)', { selector: '#finding-new-name-fr' }),
'Nouv',
)
await user.type(
screen.getByLabelText('Nom (EN)', { selector: '#finding-new-name-en' }),
'New',
)
await user.selectOptions(
screen.getByLabelText('Type de catégorie'),
'anamnesis',
)
await user.click(screen.getByRole('button', { name: 'Créer' }))
const categories = doc().finding_zones[0].categories
expect(categories.map((c) => c.id)).toEqual(['fcat-a', expect.any(String)])
expect(categories[0].children[0].children).toHaveLength(1)
})
it('disables « Ajouter un constat » on a zone and at depth 8', async () => {
let text = treeText()
let path = ['fcat-a', 'node-a', 'node-b']
@@ -0,0 +1,41 @@
/** N1 (C40): the tab a version opens on. */
import { afterEach, describe, expect, it, vi } from 'vitest'
import { initialTab } from '@/editor/tabs'
import { emptyText } from '../helpers/editorFixtures'
import {
baseText,
openReady,
resetStore,
store,
} from '../helpers/editorHarness'
vi.mock('@/lib/supabase', () => ({ getSupabaseClient: () => ({}) }))
vi.mock('@faunosteo/supabase', async (orig) => ({
...(await orig<typeof import('@faunosteo/supabase')>()),
getSheetVersion: vi.fn(),
downloadSheetDrawing: vi.fn(),
saveSheetDraft: vi.fn(),
getOfficialSheetAdmin: vi.fn(),
submitSheetReview: vi.fn(),
}))
afterEach(resetStore)
async function stateOf(text: string) {
await openReady({ text })
return store.getState().previewState!
}
describe('initialTab', () => {
it('opens an empty new draft on Général', async () => {
expect(initialTab(await stateOf(emptyText()), 'wide')).toBe('general')
})
it('opens a draft with a measured view on Annotations', async () => {
expect(initialTab(await stateOf(baseText()), 'wide')).toBe('annotations')
})
it('keeps Annotations on a tier that does not list Général', async () => {
expect(initialTab(await stateOf(emptyText()), 'small')).toBe('annotations')
})
})
@@ -0,0 +1,16 @@
import { describe, expect, it } from 'vitest'
import { pluralKey } from '@/editor/plural'
describe('pluralKey', () => {
it('treats 0 and 1 as singular in French', () => {
expect(pluralKey('fr', 'k', 0)).toBe('k_one')
expect(pluralKey('fr', 'k', 1)).toBe('k_one')
expect(pluralKey('fr', 'k', 2)).toBe('k_other')
})
it('treats only 1 as singular in English', () => {
expect(pluralKey('en', 'k', 0)).toBe('k_other')
expect(pluralKey('en', 'k', 1)).toBe('k_one')
expect(pluralKey('en', 'k', 2)).toBe('k_other')
})
})
@@ -150,6 +150,36 @@ describe('Vues et illustrations: drawing states', () => {
expect(screen.queryByText(/introuvable/)).toBeNull()
})
it('use-parent asks first: cancel changes nothing, confirm commits once, undo restores', async () => {
const own = detail()
;(own.value as { svg_asset_id: string | null }).svg_asset_id = ASSET
await openReady({ text: insert(baseText(), own) })
const user = userEvent.setup()
render(<ViewsTab {...props} />)
const open = () =>
user.click(
screen.getByRole('button', {
name: "Utiliser l'illustration de la vue parente",
}),
)
await open()
const dialog = screen.getByRole('dialog')
expect(dialog).toHaveTextContent(/reste enregistré/)
await user.click(within(dialog).getByRole('button', { name: 'Annuler' }))
expect(doc().views[1]).toMatchObject({ svg_asset_id: ASSET })
expect(store.getState().undo).toHaveLength(0)
await open()
await user.click(
within(screen.getByRole('dialog')).getByRole('button', {
name: "Utiliser l'illustration parente",
}),
)
expect(doc().views[1]).toMatchObject({ svg_asset_id: null })
expect(store.getState().undo).toHaveLength(1)
store.getState().undoStep()
expect(doc().views[1]).toMatchObject({ svg_asset_id: ASSET })
})
it('read-only shows states as text and no action', async () => {
await openReady({ text: insert(baseText(), detail()) })
render(<ViewsTab {...props} readOnly />)
@@ -57,9 +57,9 @@ describe('Vérification panel', () => {
it('shows the counts, the warning apart, the size and the groups', async () => {
await openReady()
render(<VerificationTab {...props} />)
expect(screen.getByText('0 erreurs bloquantes')).toBeTruthy()
expect(screen.getByText('1 avertissements')).toBeTruthy()
expect(screen.getByText('1 éléments à confirmer')).toBeTruthy()
expect(screen.getByText('0 erreur bloquante')).toBeTruthy()
expect(screen.getByText('1 avertissement')).toBeTruthy()
expect(screen.getByText('1 élément à confirmer')).toBeTruthy()
expect(screen.getByRole('heading', { name: 'Avertissements' })).toBeTruthy()
expect(
screen.getByText(/lié(e)? à aucune zone|liée à aucune zone/),
@@ -75,7 +75,7 @@ describe('Vérification panel', () => {
await openReady({ text: textWithError() })
const user = userEvent.setup()
render(<VerificationTab {...props} />)
expect(screen.getByText('1 erreurs bloquantes')).toBeTruthy()
expect(screen.getByText('1 erreur bloquante')).toBeTruthy()
expect(screen.getAllByText('Sans tracé')).toHaveLength(2)
expect(screen.getByText(/n'a pas de géométrie/)).toBeTruthy()
await user.click(
@@ -96,7 +96,7 @@ describe('Vérification panel', () => {
}) as HTMLButtonElement
expect(button.disabled).toBe(true)
expect(
screen.getByText('Corrigez les 1 erreurs bloquantes pour soumettre.'),
screen.getByText("Corrigez l'erreur bloquante pour soumettre."),
).toBeTruthy()
})
@@ -104,7 +104,7 @@ describe('Vérification panel', () => {
useLocaleStore.setState({ locale: 'en' })
await openReady({ text: textWithError() })
render(<VerificationTab {...props} />)
expect(screen.getByText('1 blocking errors')).toBeTruthy()
expect(screen.getByText('1 blocking error')).toBeTruthy()
expect(screen.getByText(/This annotation has no geometry/)).toBeTruthy()
expect(screen.getAllByRole('button', { name: 'Go to Bare' })).toHaveLength(
2,
@@ -115,7 +115,7 @@ describe('Vérification panel', () => {
await openReady()
render(<VerificationTab {...props} readOnly />)
expect(screen.queryByRole('button', { name: SUBMIT })).toBeNull()
expect(screen.getByText('0 erreurs bloquantes')).toBeTruthy()
expect(screen.getByText('0 erreur bloquante')).toBeTruthy()
})
})