fix(editor): overview rows ask first, no empty save, board 31 icons
U2 Task 6 review by self: - The overview stays shown during a selection (A3): its rows and view rows now go through the drawing guard, so a started move or redraw asks before a click there drops it (R-12). Was a regression: the column was unreachable while selected before Task 6. - The edit form compares and merges trimmed names and colour: a space typed alone is no change and writes no `update`. - A layer opened with no opener (reload, Forward) returns the focus to its row on close. - Board 31 A: icons on « Modifier », « Modifier la forme » (the shape's glyph), « Marquer comme relu »; « Supprimer » as red text with its trash icon. - Tests: overview row and view row ask during a started move; a row asks during a started redraw; whitespace-only save; unnamed link read rows; focus back to the row with no opener. Dead helpers removed (tests/helpers openProperties, e2e propertiesDialog). Mapping: the point-edit « Enter on the selected row … asks first » test (which replaced « Toutes les annotations asks first ») keeps its place; the overview-row path it did not cover now has its own test.
This commit is contained in:
1 parent
cd794f3c39
commit
ebcf2723a0
10 files changed
+145
-25
No files matched your search
@@ -12,6 +12,9 @@ export type GlyphName =
|
||||
| 'deselect'
|
||||
| 'move'
|
||||
| 'properties'
|
||||
| 'edit'
|
||||
| 'check'
|
||||
| 'trash'
|
||||
|
||||
/** The editor's one glyph table (24-unit grid strokes); `book` and `close` are in `Icon`. */
|
||||
const GLYPHS: Record<GlyphName, string> = {
|
||||
@@ -27,6 +30,9 @@ const GLYPHS: Record<GlyphName, string> = {
|
||||
search: 'M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14zM20 20l-4-4',
|
||||
move: 'M12 3v18M3 12h18M9 6l3-3 3 3M9 18l3 3 3-3M6 9l-3 3 3 3M18 9l3 3-3 3',
|
||||
properties: 'M7 3h7l4 4v14H7zM14 3v4h4M10 12h5M10 16h5',
|
||||
edit: 'M4 20h4L19 9l-4-4L4 16zM14 6l4 4',
|
||||
check: 'M5 12l5 5L19 7',
|
||||
trash: 'M5 7h14M10 7V4h4v3M7 7l1 13h8l1-13',
|
||||
deselect:
|
||||
'M4 8V5a1 1 0 0 1 1-1h3M16 4h3a1 1 0 0 1 1 1v3M20 16v3a1 1 0 0 1-1 1h-3M8 20H5a1 1 0 0 1-1-1v-3M9 9l6 6M15 9l-6 6',
|
||||
}
|
||||
|
||||
@@ -34,6 +34,13 @@ export interface AnnotationDialogProps {
|
||||
}
|
||||
|
||||
const EDIT_BUTTON_ID = 'annotation-edit-button'
|
||||
|
||||
/** « Modifier la forme » shows the shape it edits (board 31 A, B). */
|
||||
const SHAPE_GLYPH = {
|
||||
point: 'point',
|
||||
zone: 'zone',
|
||||
detail_trigger: 'link',
|
||||
} as const
|
||||
const ACTION = 'min-h-11 gap-1.5 xl:min-h-9'
|
||||
|
||||
/**
|
||||
@@ -91,6 +98,7 @@ function StatusAction({ annotation }: { annotation: Annotation }) {
|
||||
className={ACTION}
|
||||
onClick={() => mark(reviewed ? 'to_confirm' : 'reviewed')}
|
||||
>
|
||||
{!reviewed && <EditorGlyph name="check" size={16} />}
|
||||
{t(
|
||||
reviewed
|
||||
? 'editor.annotations.to_confirm'
|
||||
@@ -143,6 +151,7 @@ function ReadActions(props: ReadProps) {
|
||||
className={ACTION}
|
||||
onClick={props.onEdit}
|
||||
>
|
||||
<EditorGlyph name="edit" size={16} />
|
||||
{t('editor.findings.edit')}
|
||||
</Button>
|
||||
{shapeEditable && (
|
||||
@@ -153,7 +162,7 @@ function ReadActions(props: ReadProps) {
|
||||
className={ACTION}
|
||||
onClick={props.onEditShape}
|
||||
>
|
||||
<EditorGlyph name="move" size={16} />
|
||||
<EditorGlyph name={SHAPE_GLYPH[annotation.kind]} size={16} />
|
||||
{t('editor.annotations.edit_shape')}
|
||||
</Button>
|
||||
)}
|
||||
@@ -163,10 +172,12 @@ function ReadActions(props: ReadProps) {
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="danger"
|
||||
className={ACTION}
|
||||
variant="ghost"
|
||||
// Board 31 A: red text on the right, the confirmation does the deleting.
|
||||
className={`${ACTION} text-[var(--color-danger-strong)]!`}
|
||||
onClick={() => setDeleting(true)}
|
||||
>
|
||||
<EditorGlyph name="trash" size={16} />
|
||||
{t('editor.action.delete')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -54,8 +54,17 @@ function draftOf(annotation: Annotation): Draft {
|
||||
}
|
||||
}
|
||||
|
||||
/** The draft as it would be saved: names and colour trimmed. */
|
||||
const normalized = (draft: Draft): Draft => ({
|
||||
...draft,
|
||||
fr: draft.fr.trim(),
|
||||
en: draft.en.trim(),
|
||||
color: draft.color.trim(),
|
||||
})
|
||||
|
||||
/** A space typed and nothing else is no change: no dirty guard, no empty `update`. */
|
||||
const sameDraft = (a: Draft, b: Draft) =>
|
||||
JSON.stringify(a) === JSON.stringify(b)
|
||||
JSON.stringify(normalized(a)) === JSON.stringify(normalized(b))
|
||||
|
||||
/** The names as saved: trimmed, or none for a link left with both blank. */
|
||||
function namesOf(annotation: Annotation, draft: Draft) {
|
||||
@@ -69,7 +78,9 @@ function namesOf(annotation: Annotation, draft: Draft) {
|
||||
* change made meanwhile elsewhere (a drag, a review toggle) is never overwritten.
|
||||
*/
|
||||
function merged(current: Annotation, first: Draft, draft: Draft): Annotation {
|
||||
const changed = (key: keyof Draft) => first[key] !== draft[key]
|
||||
const was = normalized(first)
|
||||
const now = normalized(draft)
|
||||
const changed = (key: keyof Draft) => was[key] !== now[key]
|
||||
const value: Record<string, unknown> = { ...current }
|
||||
if (changed('fr') || changed('en')) value.name = namesOf(current, draft)
|
||||
if (changed('categoryId')) value.category_id = draft.categoryId
|
||||
|
||||
@@ -362,9 +362,15 @@ function SidePanel({
|
||||
readOnly={false}
|
||||
filter={ui.filter}
|
||||
onFilter={(term) => dispatch({ type: 'filter', term })}
|
||||
onSelectView={(id) => dispatch({ type: 'view', viewId: id })}
|
||||
// The column stays shown during a selection (A3): a row or a view that would drop
|
||||
// a started move or redraw asks first (R-12).
|
||||
onSelectView={(id) =>
|
||||
guarded(() => dispatch({ type: 'view', viewId: id }))()
|
||||
}
|
||||
selectedId={scene.selected?.id ?? null}
|
||||
onSelectAnnotation={(id) => dispatch({ type: 'select', id })}
|
||||
onSelectAnnotation={(id) =>
|
||||
guarded(() => dispatch({ type: 'select', id }))()
|
||||
}
|
||||
onOpenAnnotation={(id) => scene.onOpen(id, 'drawing')}
|
||||
onOpenSection={scene.onOpenSection}
|
||||
/>
|
||||
|
||||
@@ -48,6 +48,11 @@ export function useDialogOpening(
|
||||
const opened = useRef<{ id: string; by: OpenedBy } | null>(null)
|
||||
const latest = useRef(layer)
|
||||
latest.current = layer
|
||||
// A layer opened by a reload or a Forward has no opener: its row is the way back.
|
||||
const shown = layer?.view?.id
|
||||
if (shown && opened.current?.id !== shown) {
|
||||
opened.current = { id: shown, by: 'drawing' }
|
||||
}
|
||||
const open: OpenDialog = (id, by) => {
|
||||
const go = () => {
|
||||
opened.current = { id, by }
|
||||
|
||||
Reference in new issue
Block a user