From 5682978e3151892e7bcf484f11aee6709c955a51 Mon Sep 17 00:00:00 2001 From: hchsu Date: Tue, 13 Apr 2021 16:18:47 +0800 Subject: [PATCH] Add Confirmation for Day/Note Deletion --- client/src/views/Day.vue | 49 +++++++++++++++++++++++++-------------- client/src/views/Note.vue | 47 +++++++++++++++++++++++-------------- 2 files changed, 61 insertions(+), 35 deletions(-) diff --git a/client/src/views/Day.vue b/client/src/views/Day.vue index 1512a4b..65056f7 100644 --- a/client/src/views/Day.vue +++ b/client/src/views/Day.vue @@ -151,23 +151,36 @@ export default class Day extends Vue { } public async deleteNote() { - if (!this.day.uuid) { - return; - } - - try { - await NoteService.deleteNote(this.day.uuid); - this.sidebar.getEvents(); - this.sidebar.getSidebarInfo(); - this.$router.push({name: 'Home Redirect'}); - } catch(e) { - this.$buefy.toast.open({ - duration: 5000, - message: 'There was an error deleting note. Please try again.', - position: 'is-top', - type: 'is-danger' - }); - } + this.$buefy.dialog.confirm({ + title: 'Deleting Daily Note', + message: 'Are you sure you want to delete this daily note? This action cannot be undone!', + confirmText: 'Delete', + focusOn: 'cancel', + type: 'is-danger', + hasIcon: true, + onConfirm: async () => { + if (!this.day.uuid) { + return; + } + try { + await NoteService.deleteNote(this.day.uuid); + this.sidebar.getEvents(); + this.sidebar.getSidebarInfo(); + this.$router.push({name: 'Home Redirect'}); + } catch(e) { + this.$buefy.toast.open({ + duration: 5000, + message: 'There was an error deleting note. Please try again.', + position: 'is-top', + type: 'is-danger' + }); + } + this.$buefy.toast.open({ + duration: 2000, + message: 'Daily note deleted!' + }); + } + }) } public setDefaultText() { @@ -202,4 +215,4 @@ export default class Day extends Vue { height: 100vh; position: relative; } - \ No newline at end of file + diff --git a/client/src/views/Note.vue b/client/src/views/Note.vue index 6005a89..88e1692 100644 --- a/client/src/views/Note.vue +++ b/client/src/views/Note.vue @@ -115,22 +115,35 @@ export default class Note extends Vue { } public async deleteNote() { - if (!this.note.uuid) { - return; - } - - try { - await NoteService.deleteNote(this.note.uuid); - this.sidebar.getSidebarInfo(); - this.$router.push({name: 'Home Redirect'}); - } catch(e) { - this.$buefy.toast.open({ - duration: 5000, - message: 'There was an error deleting note. Please try again.', - position: 'is-top', - type: 'is-danger' - }); - } + this.$buefy.dialog.confirm({ + title: 'Deleting Note', + message: 'Are you sure you want to delete this note? This action cannot be undone!', + confirmText: 'Delete', + focusOn: 'cancel', + type: 'is-danger', + hasIcon: true, + onConfirm: async () => { + if (!this.note.uuid) { + return; + } + try { + await NoteService.deleteNote(this.note.uuid); + this.sidebar.getSidebarInfo(); + this.$router.push({name: 'Home Redirect'}); + } catch(e) { + this.$buefy.toast.open({ + duration: 5000, + message: 'There was an error deleting note. Please try again.', + position: 'is-top', + type: 'is-danger' + }); + } + this.$buefy.toast.open({ + duration: 2000, + message: 'Note deleted!' + }); + } + }) } public valChanged(data: string) { @@ -153,4 +166,4 @@ export default class Note extends Vue { height: 100vh; position: relative; } - \ No newline at end of file +