feat(editor): drawing guard before navigations drop a started move (R-12)
The move mode lives in the work store with its document stamp. guardDrawing ends an unstarted mode at once and asks « Abandonner le déplacement ? » (DrawingGuardDialog, at workspace level) once work is started, before a tab, a section, « Aller à », Back and a history jump out of the editor; the leave guard and sign-out count started work. An undo from the header, Ctrl+Z or the message only cancels a pending mode or preview (R-13), and a document change drops a stale mode, keeping a started one to be said. ConfirmDialog takes an optional body. Strings for Task 4 added.
This commit is contained in:
1 parent
8cd1bda6c2
commit
2882821661
18 files changed
+465
-37
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import { endMode, guardWork, useAnnotationWork } from './workStore'
|
||||
|
||||
/**
|
||||
* The drawing guard (R-12), asked by every navigation that would drop the drawing's work:
|
||||
* a tab, a section, « Aller à », a view chip, a tool, Back, leaving the editor. Nothing
|
||||
* started: an unstarted mode ends at once and the caller goes on (true). Work started:
|
||||
* the question is shown (`DrawingGuardDialog`) and `proceed` waits for « Abandonner »
|
||||
* (false).
|
||||
*/
|
||||
export function guardDrawing(proceed: () => void): boolean {
|
||||
const work = guardWork(useAnnotationWork.getState())
|
||||
if (work === null) {
|
||||
endMode()
|
||||
return true
|
||||
}
|
||||
useAnnotationWork.setState({ question: { work, proceed } })
|
||||
return false
|
||||
}
|
||||
|
||||
/** « Continuer » keeps the work as it is; « Abandonner » drops it and makes the move. */
|
||||
export function answerDrawing(discard: boolean): void {
|
||||
const { question } = useAnnotationWork.getState()
|
||||
useAnnotationWork.setState({ question: null })
|
||||
if (!discard || !question) return
|
||||
endMode()
|
||||
question.proceed()
|
||||
}
|
||||
Reference in new issue
Block a user