Skip to content

Commit

Permalink
Merge pull request #27 from hhhhhojeihsu/deletion_confirmation
Browse files Browse the repository at this point in the history
Add Confirmation for Day/Note Deletion
  • Loading branch information
m0ngr31 authored Apr 13, 2021
2 parents f3327e2 + 5682978 commit b32860e
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 35 deletions.
49 changes: 31 additions & 18 deletions client/src/views/Day.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 <b>delete</b> 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() {
Expand Down Expand Up @@ -202,4 +215,4 @@ export default class Day extends Vue {
height: 100vh;
position: relative;
}
</style>
</style>
47 changes: 30 additions & 17 deletions client/src/views/Note.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 <b>delete</b> 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) {
Expand All @@ -153,4 +166,4 @@ export default class Note extends Vue {
height: 100vh;
position: relative;
}
</style>
</style>

0 comments on commit b32860e

Please sign in to comment.