diff --git a/.claude/audits/2026-11-03-v1-2-6-label-proposals.md b/.claude/audits/2026-11-03-v1-2-6-label-proposals.md index 95623bcb..ceb49f6c 100644 --- a/.claude/audits/2026-11-03-v1-2-6-label-proposals.md +++ b/.claude/audits/2026-11-03-v1-2-6-label-proposals.md @@ -81,3 +81,99 @@ Status column: `ratified` = REVUE.md wording; `plan wording` = quoted in the pla | `editor.draft.conflict.reload_unknown_ask` | Abandonner vos modifications et recharger la version du serveur ? | Abandon your changes and reload the server version? | Reload confirmation, N unknown | proposal | | `editor.draft.conflict.keep_ask` | Remplacer la révision {revision} par votre version ? | Replace revision {revision} with your version? | Keep confirmation, author and date unknown | plan wording FR (author omitted); EN proposal | | `editor.draft.conflict.keep_ask_by` | Remplacer la révision {revision} ({who}, {date}) par votre version ? | Replace revision {revision} ({who}, {date}) with your version? | Keep confirmation, author and date known | plan wording FR; EN proposal | + +## Lot F (Général, Références, Vertèbres, delete with dependents) + +| Key | FR | EN | Where | Status | +|---|---|---|---|---| +| `editor.action.delete` | Supprimer | Delete | Row delete button | plan wording | +| `editor.action.remove` | Retirer | Remove | Remove an author | proposal | +| `editor.action.move_up` | Monter | Move up | Reorder button label (↑) | proposal | +| `editor.action.move_down` | Descendre | Move down | Reorder button label (↓) | proposal | +| `editor.field.required` | Ce champ est obligatoire. | This field is required. | Blank required field | proposal | +| `editor.field.required_names` | Renseignez le nom en français et en anglais. | Fill in the name in French and in English. | Creation form, names missing | proposal | +| `editor.field.integer` | Indiquez un nombre entier. | Enter a whole number. | Count field not a whole number | proposal | +| `editor.field.choose` | Choisir… | Choose… | Empty option of a required choice | proposal | +| `editor.refusal.blocked` | La modification n'a pas été appliquée. | The change was not applied. | Command blocked by the store | proposal | +| `editor.refusal.recovery` | Répondez d'abord à la copie locale proposée en haut de page. | First answer the local copy offered at the top of the page. | Command blocked by a pending recovery offer | proposal | +| `editor.refusal.core.unknown_key` | Cet élément n'existe plus dans le brouillon. | This element no longer exists in the draft. | Core refusal unknown_key | proposal | +| `editor.refusal.core.duplicate_key` | Un élément porte déjà cet identifiant. | An element already has this identifier. | Core refusal duplicate_key | proposal | +| `editor.refusal.core.invalid_target` | Cette modification ne s'applique pas à cet élément. | This change does not apply to this element. | Core refusal invalid_target | proposal | +| `editor.refusal.core.id_changed` | L'identifiant ou le code d'un élément ne se modifie pas. | An element's identifier or code cannot be changed. | Core refusal id_changed | proposal | +| `editor.refusal.core.invalid_position` | Cette position n'existe pas dans la liste. | This position does not exist in the list. | Core refusal invalid_position | proposal | +| `editor.refusal.core.too_deep` | L'arbre est trop profond (8 niveaux au plus). | The tree is too deep (8 levels at most). | Core refusal too_deep | plan wording (depth 8) | +| `editor.refusal.core.has_dependents` | D'autres éléments utilisent encore celui-ci. | Other elements still use this one. | Core refusal has_dependents | proposal | +| `editor.refusal.core.other` | Le contrôle du document refuse cette valeur ({kind}). | The document check refuses this value ({kind}). | Any other core refusal; {kind} = the core's closed kind | proposal | +| `editor.element.sheet` | Fiche | Sheet | Dependents list, element kind | proposal | +| `editor.element.reference` | Référence | Reference | Dependents list, element kind | proposal | +| `editor.element.region` | Région vertébrale | Vertebral region | Dependents list, element kind | proposal | +| `editor.element.category` | Catégorie | Category | Dependents list, element kind | proposal | +| `editor.element.view` | Vue | View | Dependents list, element kind | proposal | +| `editor.element.annotation` | Annotation | Annotation | Dependents list, element kind | proposal | +| `editor.element.zone` | Zone de constats | Finding zone | Dependents list, element kind | proposal | +| `editor.element.finding` | Constat | Finding | Dependents list, element kind | proposal | +| `editor.relation.drawn_in` | dessinée dans cette vue | drawn in this view | Dependents list, relation | proposal | +| `editor.relation.child_view` | vue de détail de cette vue | detail view of this view | Dependents list, relation | proposal | +| `editor.relation.opens` | ouvre cette vue | opens this view | Dependents list, relation | proposal | +| `editor.relation.uses_category` | utilise cette catégorie | uses this category | Dependents list, relation | proposal | +| `editor.relation.links_zone` | est liée à cette zone de constats | is linked to this finding zone | Dependents list, relation | proposal | +| `editor.relation.cites` | cite cette référence | cites this reference | Dependents list, relation | proposal | +| `editor.relation.uses_region` | utilise cette région vertébrale | uses this vertebral region | Dependents list, relation | proposal | +| `editor.relation.descendant` | fait partie de cet élément | is part of this element | Dependents list, relation | proposal | +| `editor.delete.title` | Supprimer « {name} » ? | Delete "{name}"? | Delete dialog title | proposal | +| `editor.delete.ask` | Supprimer « {name} » du brouillon ? | Delete "{name}" from the draft? | Delete dialog, no dependents | proposal | +| `editor.delete.descendants` | Les éléments suivants seront aussi supprimés : | These elements will be deleted too: | Delete dialog, descendants listed | plan wording (meaning) | +| `editor.delete.blocked` | « {name} » ne peut pas être supprimé : les éléments suivants l'utilisent encore. | "{name}" cannot be deleted: the following elements still use it. | Delete dialog, refusal with dependents | plan wording (meaning) | +| `editor.delete.lookup_failed` | Impossible de vérifier ce qui utilise cet élément. Réessayez. | Could not check what uses this element. Try again. | Delete dialog, dependents lookup failed | proposal | +| `editor.delete.confirm` | Supprimer | Delete | Delete dialog, confirm button | proposal | +| `editor.delete.cancel` | Annuler | Cancel | Delete dialog, cancel button | proposal | +| `editor.delete.close` | Fermer | Close | Delete dialog, close button | proposal | +| `editor.general.texts` | Fiche | Sheet | Général, section title | proposal | +| `editor.general.name_fr` | Nom (FR) | Name (FR) | Général, sheet name | plan wording FR; EN proposal | +| `editor.general.name_en` | Nom (EN) | Name (EN) | Général, sheet name | plan wording FR; EN proposal | +| `editor.general.description_fr` | Description (FR) | Description (FR) | Général | proposal | +| `editor.general.description_en` | Description (EN) | Description (EN) | Général | proposal | +| `editor.general.scope_disclaimer_fr` | Périmètre et limites (FR) | Scope and limits (FR) | Général, scope disclaimer | proposal | +| `editor.general.scope_disclaimer_en` | Périmètre et limites (EN) | Scope and limits (EN) | Général, scope disclaimer | proposal | +| `editor.general.attribution` | Attribution | Attribution | Général, section title | proposal | +| `editor.general.authors` | Auteurs | Authors | Général, authors list | proposal | +| `editor.general.author_new` | Nouvel auteur | New author | Général, add-author field | proposal | +| `editor.general.author_add` | Ajouter l'auteur | Add the author | Général, add-author button | proposal | +| `editor.general.author_remove` | Retirer {name} | Remove {name} | Général, remove-author accessible name | proposal | +| `editor.general.license` | Licence | Licence | Général | proposal | +| `editor.general.notes` | Notes | Notes | Général, attribution notes | proposal | +| `editor.general.categories` | Catégories d'annotation | Annotation categories | Général, section title | plan wording FR; EN proposal | +| `editor.general.category_name_fr` | Nom de la catégorie (FR) | Category name (FR) | Category field | proposal | +| `editor.general.category_name_en` | Nom de la catégorie (EN) | Category name (EN) | Category field | proposal | +| `editor.general.category_color` | Couleur | Colour | Category field | proposal | +| `editor.general.category_color_hint` | Facultative, au format #rrggbb. | Optional, as #rrggbb. | Category colour hint | proposal | +| `editor.general.category_new` | Nouvelle catégorie | New category | Category creation form | proposal | +| `editor.general.category_add` | Ajouter la catégorie | Add the category | Category creation button | proposal | +| `editor.reference.empty` | Aucune référence pour l'instant. | No reference yet. | Références, empty list | proposal | +| `editor.reference.type` | Type | Type | Reference field | proposal | +| `editor.reference.citation` | Citation | Citation | Reference field | proposal | +| `editor.reference.url` | Adresse web (URL) | Web address (URL) | Reference field | proposal | +| `editor.reference.doi` | DOI | DOI | Reference field | proposal | +| `editor.reference.new` | Nouvelle référence | New reference | Reference creation form | proposal | +| `editor.reference.add` | Ajouter la référence | Add the reference | Reference creation button | proposal | +| `editor.reference.required` | Choisissez un type et renseignez la citation. | Choose a type and fill in the citation. | Reference creation, missing field | proposal | +| `editor.reference.type.book` | Livre | Book | Reference type | proposal | +| `editor.reference.type.journal` | Article de revue | Journal article | Reference type | proposal | +| `editor.reference.type.standard` | Norme | Standard | Reference type | proposal | +| `editor.reference.type.legal` | Texte juridique | Legal text | Reference type | proposal | +| `editor.reference.type.web` | Site web | Web page | Reference type | proposal | +| `editor.reference.type.manual` | Manuel | Manual | Reference type | proposal | +| `editor.vertebra.empty` | Aucune région vertébrale pour l'instant. | No vertebral region yet. | Vertèbres, empty list | proposal | +| `editor.vertebra.code` | Code | Code | Region field (read-only after creation) | proposal | +| `editor.vertebra.name_fr` | Nom (FR) | Name (FR) | Region field | proposal | +| `editor.vertebra.name_en` | Nom (EN) | Name (EN) | Region field | proposal | +| `editor.vertebra.count` | Nombre de vertèbres | Number of vertebrae | Region field | proposal | +| `editor.vertebra.range` | Plage possible | Possible range | Region range, read-only label | proposal | +| `editor.vertebra.range_min` | Plage : minimum | Range: minimum | Region range field | proposal | +| `editor.vertebra.range_max` | Plage : maximum | Range: maximum | Region range field | proposal | +| `editor.vertebra.range_apply` | Appliquer la plage | Apply the range | Region range button | proposal | +| `editor.vertebra.range_pair` | Indiquez les deux bornes de la plage, ou aucune. | Fill in both bounds of the range, or neither. | Region range, one bound missing | proposal | +| `editor.vertebra.range_number` | Les bornes de la plage sont des nombres entiers. | The range bounds are whole numbers. | Region range, not numbers | proposal | +| `editor.vertebra.new` | Nouvelle région vertébrale | New vertebral region | Region creation form | proposal | +| `editor.vertebra.add` | Ajouter la région | Add the region | Region creation button | proposal | +| `editor.vertebra.required` | Renseignez le code et les noms français et anglais. | Fill in the code and the French and English names. | Region creation, missing field | proposal | diff --git a/apps/app/src/components/editor/DeleteDialog.tsx b/apps/app/src/components/editor/DeleteDialog.tsx new file mode 100644 index 00000000..12064d18 --- /dev/null +++ b/apps/app/src/components/editor/DeleteDialog.tsx @@ -0,0 +1,167 @@ +import { useMemo, useState } from 'react' +import type { + AnatomicalSheetDocument, + Dependent, + ElementKey, +} from '@faunosteo/core-wasm/types' +import Button from '@/components/ui/Button' +import Dialog from '@/components/ui/Dialog' +import { dependentsOf } from '@/editor/core/editOps' +import { refusalMessage } from '@/editor/refusal' +import { elementLabel, useSheetDocument } from '@/editor/sheetDocument' +import { useEditorStore } from '@/editor/state/editorStore' +import { useT } from '@/i18n/useT' +import { useLocaleStore } from '@/state/localeStore' + +export interface DeleteTarget { + key: ElementKey + /** The element's name as the list shows it. */ + label: string +} + +export interface DeleteDialogProps { + /** null = closed. The dialog asks the core for the dependents each time it opens. */ + target: DeleteTarget | null + onClose: () => void +} + +/** + * Delete with dependents (shared by the Général, Références, Vertèbres, Vues and Constats + * panels): the core lists what still names the element; if anything does, the dialog + * shows the list and offers no deletion (the core would refuse it); descendants go with + * the element and are listed in the confirmation. + */ +export default function DeleteDialog({ target, onClose }: DeleteDialogProps) { + const t = useT() + const doc = useSheetDocument() + const heading = t('editor.delete.title').replace( + '{name}', + target?.label ?? '', + ) + return ( + + {target && doc && ( + + )} + + ) +} + +function DeleteBody({ + target, + doc, + onClose, +}: { + target: DeleteTarget + doc: AnatomicalSheetDocument + onClose: () => void +}) { + const t = useT() + const [failure, setFailure] = useState(null) + const found = useMemo( + () => dependentsOf(useEditorStore.getState().documentText, target.key), + [target.key], + ) + if (!found.ok) { + return ( + + ) + } + const blocking = found.value.filter((d) => d.relation !== 'descendant') + const descendants = found.value.filter((d) => d.relation === 'descendant') + if (blocking.length > 0) { + return ( + <> +

+ {t('editor.delete.blocked').replace('{name}', target.label)} +

+ + + + ) + } + const confirm = () => { + const outcome = useEditorStore + .getState() + .commit({ op: 'remove', key: target.key }) + if (outcome.ok) onClose() + else setFailure(refusalMessage(t, outcome)) + } + return ( + <> +

+ {t('editor.delete.ask').replace('{name}', target.label)} +

+ {descendants.length > 0 && ( + <> +

{t('editor.delete.descendants')}

+ + + )} + {failure && ( +

+ {failure} +

+ )} +
+ + +
+ + ) +} + +function Closing({ + message, + onClose, +}: { + message?: string + onClose: () => void +}) { + const t = useT() + return ( + <> + {message &&

{message}

} +
+ +
+ + ) +} + +function DependentList({ + doc, + dependents, + withRelation = false, +}: { + doc: AnatomicalSheetDocument + dependents: readonly Dependent[] + withRelation?: boolean +}) { + const t = useT() + const locale = useLocaleStore((s) => s.locale) + return ( +
    + {dependents.map((d) => ( +
  • + {t(`editor.element.${d.element.kind}`)} «{' '} + {elementLabel(doc, d.element, locale)} » + {withRelation && <> : {t(`editor.relation.${d.relation}`)}} +
  • + ))} +
+ ) +} diff --git a/apps/app/src/components/editor/fields/DraftField.tsx b/apps/app/src/components/editor/fields/DraftField.tsx new file mode 100644 index 00000000..7e43e9bd --- /dev/null +++ b/apps/app/src/components/editor/fields/DraftField.tsx @@ -0,0 +1,38 @@ +import FormField, { fieldDescribedBy } from '@/components/ui/FormField' +import Input from '@/components/ui/Input' +import Textarea from '@/components/ui/Textarea' + +/** + * A controlled field of a creation form: it never commits, the form's own button does + * (BDR-050). The committed fields of existing elements are `TextField`. + */ +export default function DraftField({ + id, + label, + value, + onChange, + multiline, + hint, + error, +}: { + id: string + label: string + value: string + onChange: (value: string) => void + multiline?: boolean + hint?: string + error?: string +}) { + const shared = { + id, + value, + onChange: (e: { target: { value: string } }) => onChange(e.target.value), + 'aria-invalid': Boolean(error), + 'aria-describedby': fieldDescribedBy(id, hint, error), + } + return ( + + {multiline ?