From: Adam Dullage Date: Fri, 10 May 2024 12:12:13 +0000 (+0100) Subject: Add note edit cancellation confirmation modal X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=b843a1aa8f726b9b78fea51f0661b037fe912bb1;p=flatnotes.git Add note edit cancellation confirmation modal --- diff --git a/client/views/Note.vue b/client/views/Note.vue index e921e10..56374db 100644 --- a/client/views/Note.vue +++ b/client/views/Note.vue @@ -9,6 +9,16 @@ @confirm="deleteConfirmedHandler" /> + + +
@@ -107,6 +117,7 @@ const props = defineProps({ const canModify = computed(() => globalStore.authType != authTypes.readOnly); const editMode = ref(false); const globalStore = useGlobalStore(); +const isCancellationModalVisible = ref(false); const isDeleteModalVisible = ref(false); const isNewNote = computed(() => !props.title); const loadingIndicator = ref(); @@ -196,12 +207,13 @@ function deleteHandler() { } function cancelHandler() { - setBeforeUnloadConfirmation(false); - editMode.value = false; - if (!props.title) { - router.push({ name: "home" }); + if ( + newTitle.value != note.value.title || + toastEditor.value.getMarkdown() != note.value.content + ) { + isCancellationModalVisible.value = true; } else { - editMode.value = false; + cancelConfirmedHandler(); } } @@ -229,6 +241,16 @@ function saveHandler() { } // Additional Logic +function cancelConfirmedHandler() { + setBeforeUnloadConfirmation(false); + editMode.value = false; + if (!props.title) { + router.push({ name: "home" }); + } else { + editMode.value = false; + } +} + function deleteConfirmedHandler() { deleteNote(note.value.title) .then(() => {