fix(editor): resumed shape names and minor review fixes
- French fallback names: « cette nouvelle zone », « ce nouvel accès » (controller ruling: « Sommets de ce nouvel accès »); doc updated. - useZoneHandle back to 5 locals. - dropPending clears the strip hint as a kept stored change does. - Tests: the chosen vertex cleared by finishCreation itself (document unchanged) and by a view change through the guard; both fail without their clearing. Changed assertions, editor-creation-dialog.test.tsx: - « Sommets de la nouvelle zone », « Sommet 1 de la nouvelle zone » -> « … de cette nouvelle zone » (ruling) - « Sommets de le nouvel accès » -> « Sommets de ce nouvel accès » - chosen null after « Créer » (cleared by the document change, not discriminating) -> « the chosen vertex ends with a finished creation, the document unchanged »
This commit is contained in:
1 parent
a5896710e5
commit
c01c6f3145
5 files changed
+49
-22
No files matched your search
@@ -341,17 +341,15 @@ function pendingName(
|
||||
function useZoneHandle(scene: Scene, work: Work, shown: boolean) {
|
||||
const t = useT()
|
||||
const locale = useLocaleStore((s) => s.locale)
|
||||
const { resumed, target } = work
|
||||
const points = shown
|
||||
? handledPoints((resumed ?? target)?.geometry ?? null)
|
||||
: null
|
||||
if (!points) return null
|
||||
if (resumed && scene.creation) {
|
||||
const shape = work.resumed ?? work.target
|
||||
const points = shown ? handledPoints(shape?.geometry ?? null) : null
|
||||
if (!points || !shape) return null
|
||||
if (work.resumed && scene.creation) {
|
||||
const name = pendingName(scene.creation, locale, t)
|
||||
return { annotationId: PENDING_ID, name, points }
|
||||
}
|
||||
const name = annotationName(target!, scene.doc.views, locale)
|
||||
return { annotationId: target!.id, name, points }
|
||||
const name = annotationName(work.target!, scene.doc.views, locale)
|
||||
return { annotationId: shape.id, name, points }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -153,12 +153,14 @@ function changeKeys(change: GeometryChange, kind: Annotation['kind']) {
|
||||
* inactive during a creation, rev 4); the core judges it at « Créer ».
|
||||
*/
|
||||
function dropPending(
|
||||
{ context, message }: PlacementInput,
|
||||
{ context, message, dispatch }: PlacementInput,
|
||||
geometry: Geometry,
|
||||
change: GeometryChange,
|
||||
): boolean {
|
||||
if (change === 'move' || geometry.type !== 'polygon') return false
|
||||
if (!patchPendingShape(geometry)) return false
|
||||
// As a kept change of a stored zone: it ends any refusal the strip still shows.
|
||||
dispatch({ type: 'hint', hint: null })
|
||||
const text = context.t(`editor.annotations.message.${KEPT[change]}`)
|
||||
message.show(text, { undo: false, tone: 'info' })
|
||||
return true
|
||||
|
||||
@@ -1911,8 +1911,8 @@ export const fr: Dict = {
|
||||
'editor.annotations.handle.insert':
|
||||
'Ajouter un sommet après le sommet {n} de {name}',
|
||||
'editor.annotations.handle.remove': 'Retirer le sommet {n} de {name}',
|
||||
'editor.annotations.handle.unnamed.zone': 'la nouvelle zone',
|
||||
'editor.annotations.handle.unnamed.detail_trigger': 'le nouvel accès',
|
||||
'editor.annotations.handle.unnamed.zone': 'cette nouvelle zone',
|
||||
'editor.annotations.handle.unnamed.detail_trigger': 'ce nouvel accès',
|
||||
'editor.annotations.strip.vertex_chosen': '{detail} · sommet {n} choisi',
|
||||
'editor.annotations.strip.too_many_one':
|
||||
'{kind} · {count} sommet, trop pour les poignées',
|
||||
|
||||
@@ -20,7 +20,11 @@ import {
|
||||
} from '@/editor/annotations/workStore'
|
||||
import DrawingGuardDialog from '@/components/editor/annotations/DrawingGuardDialog'
|
||||
import { emptyForm } from '@/editor/annotations/creation'
|
||||
import { dropCreation, placePending } from '@/editor/annotations/creationWork'
|
||||
import {
|
||||
dropCreation,
|
||||
finishCreation,
|
||||
placePending,
|
||||
} from '@/editor/annotations/creationWork'
|
||||
import { guardDrawing } from '@/editor/annotations/drawingGuard'
|
||||
import { useLocaleStore } from '@/state/localeStore'
|
||||
import { drawnText, insert, point } from '../helpers/editorFixtures'
|
||||
@@ -259,8 +263,8 @@ describe('« Reprendre le tracé » edits the closed shape with its handles (boa
|
||||
const strip = () => screen.getByTestId('edit-strip')
|
||||
|
||||
/** A traced square, its dialog, the name typed (unless empty), then « Reprendre le tracé ». */
|
||||
async function resumed(name = 'Tibia', points = SQUARE) {
|
||||
const user = await mount()
|
||||
async function resumed(name = 'Tibia', points = SQUARE, text?: string) {
|
||||
const user = await mount(text)
|
||||
await user.click(screen.getByRole('button', { name: 'Zone' }))
|
||||
points.forEach(([x, y]) => pressAt(canvas(), x, y))
|
||||
await user.click(screen.getByRole('button', { name: 'Fermer le tracé' }))
|
||||
@@ -404,7 +408,6 @@ describe('« Reprendre le tracé » edits the closed shape with its handles (boa
|
||||
type: 'polygon',
|
||||
points: [[20, 20], [50, 20], ...SQUARE.slice(1)],
|
||||
})
|
||||
expect(useAnnotationWork.getState().chosen).toBeNull()
|
||||
})
|
||||
|
||||
it('the chosen vertex ends with the creation when it is dropped', async () => {
|
||||
@@ -415,13 +418,37 @@ describe('« Reprendre le tracé » edits the closed shape with its handles (boa
|
||||
expect(useAnnotationWork.getState().chosen).toBeNull()
|
||||
})
|
||||
|
||||
it('names: « la nouvelle zone » while the name is empty; English: « the new zone »', async () => {
|
||||
it('the chosen vertex ends with a finished creation, the document unchanged', async () => {
|
||||
await resumed()
|
||||
clickHandle('Sommet 2 de Tibia', [80, 20])
|
||||
const text = store.getState().documentText
|
||||
// No document change here: only finishCreation itself can clear the choice.
|
||||
act(() => finishCreation('anno-new', 'zone'))
|
||||
expect(store.getState().documentText).toBe(text)
|
||||
expect(useAnnotationWork.getState().chosen).toBeNull()
|
||||
})
|
||||
|
||||
it('the chosen vertex ends when a view change drops the creation', async () => {
|
||||
const user = await resumed('Tibia', SQUARE, withDetail())
|
||||
clickHandle('Sommet 2 de Tibia', [80, 20])
|
||||
expect(useAnnotationWork.getState().chosen).not.toBeNull()
|
||||
await user.click(screen.getByRole('button', { name: 'Tête' }))
|
||||
await user.click(
|
||||
within(
|
||||
await screen.findByRole('dialog', { name: 'Abandonner la création ?' }),
|
||||
).getByRole('button', { name: 'Abandonner' }),
|
||||
)
|
||||
expect(creation()).toBeNull()
|
||||
expect(useAnnotationWork.getState().chosen).toBeNull()
|
||||
})
|
||||
|
||||
it('names: « cette nouvelle zone » while unnamed; English: « the new zone »', async () => {
|
||||
await resumed('')
|
||||
expect(
|
||||
screen.getByRole('group', { name: 'Sommets de la nouvelle zone' }),
|
||||
screen.getByRole('group', { name: 'Sommets de cette nouvelle zone' }),
|
||||
).toBeInTheDocument()
|
||||
expect(
|
||||
screen.getByRole('button', { name: 'Sommet 1 de la nouvelle zone' }),
|
||||
screen.getByRole('button', { name: 'Sommet 1 de cette nouvelle zone' }),
|
||||
).toBeInTheDocument()
|
||||
act(() => useLocaleStore.setState({ locale: 'en' }))
|
||||
expect(
|
||||
@@ -429,7 +456,7 @@ describe('« Reprendre le tracé » edits the closed shape with its handles (boa
|
||||
).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('a keyboard link resumes with handles, « le nouvel accès » while unnamed', async () => {
|
||||
it('a keyboard link resumes with handles, « ce nouvel accès » while unnamed', async () => {
|
||||
const user = await mount(withDetail())
|
||||
await user.click(screen.getByRole('button', { name: 'Ajouter un accès' }))
|
||||
const shown = await dialog('Nouvel accès')
|
||||
@@ -439,7 +466,7 @@ describe('« Reprendre le tracé » edits the closed shape with its handles (boa
|
||||
await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull())
|
||||
expect(strip()).toHaveTextContent('Nouvel accès')
|
||||
expect(
|
||||
screen.getByRole('group', { name: 'Sommets de le nouvel accès' }),
|
||||
screen.getByRole('group', { name: 'Sommets de ce nouvel accès' }),
|
||||
).toBeInTheDocument()
|
||||
expect(creation()).toMatchObject({ closed: true, dialog: false })
|
||||
})
|
||||
|
||||
@@ -244,8 +244,8 @@ core, since the new shape is not in the document until « Créer »:
|
||||
ghost stays drawn as above, and the handle layer draws the polygon handles
|
||||
on it exactly as on a selected polygon (« + », vertices, the chosen vertex's
|
||||
« − » bubble, the 40-vertex cap, the R-9 zoom rule). Their names carry the
|
||||
form's name in the current locale, or « la nouvelle zone » / « le nouvel
|
||||
accès » while it is empty. During a vertex drag the ghost stays at its last
|
||||
form's name in the current locale, or « cette nouvelle zone » / « ce nouvel
|
||||
accès » while it is empty (« Sommets de ce nouvel accès »). During a vertex drag the ghost stays at its last
|
||||
place and the dragged outline is drawn as a selection preview (dashed ink,
|
||||
its vertices), without the grey old place; the loupe follows a finger as on
|
||||
a stored zone. A change of the shape only replaces the ghost's geometry: the
|
||||
|
||||
Reference in new issue
Block a user