diff --git a/src/public/app/services/branches.js b/src/public/app/services/branches.js
index ef04344b9..c51615524 100644
--- a/src/public/app/services/branches.js
+++ b/src/public/app/services/branches.js
@@ -68,7 +68,7 @@ async function moveToParentNote(branchIdsToMove, newParentBranchId) {
}
}
-async function deleteNotes(branchIdsToDelete) {
+async function deleteNotes(branchIdsToDelete, forceDeleteAllClones = false) {
branchIdsToDelete = filterRootNote(branchIdsToDelete);
if (branchIdsToDelete.length === 0) {
@@ -83,7 +83,7 @@ async function deleteNotes(branchIdsToDelete) {
}
else {
({proceed, deleteAllClones, eraseNotes} = await new Promise(res =>
- appContext.triggerCommand('showDeleteNotesDialog', {branchIdsToDelete, callback: res})));
+ appContext.triggerCommand('showDeleteNotesDialog', {branchIdsToDelete, callback: res, forceDeleteAllClones})));
}
if (!proceed) {
diff --git a/src/public/app/widgets/buttons/note_actions.js b/src/public/app/widgets/buttons/note_actions.js
index fe486f299..090d67309 100644
--- a/src/public/app/widgets/buttons/note_actions.js
+++ b/src/public/app/widgets/buttons/note_actions.js
@@ -1,5 +1,6 @@
import NoteContextAwareWidget from "../note_context_aware_widget.js";
import utils from "../../services/utils.js";
+import branchService from "../../services/branches.js";
const TPL = `
`;
@@ -65,6 +67,15 @@ export default class NoteActionsWidget extends NoteContextAwareWidget {
this.$widget.on('click', '.dropdown-item', () => this.$widget.find("[data-toggle='dropdown']").dropdown('toggle'));
this.$openNoteExternallyButton = this.$widget.find(".open-note-externally-button");
+
+ this.$deleteNoteButton = this.$widget.find(".delete-note-button");
+ this.$deleteNoteButton.on("click", () => {
+ if (this.note.noteId === 'root') {
+ return;
+ }
+
+ branchService.deleteNotes([this.note.getParentBranches()[0].branchId], true);
+ });
}
refreshWithNote(note) {
diff --git a/src/public/app/widgets/dialogs/delete_notes.js b/src/public/app/widgets/dialogs/delete_notes.js
index 24801ba96..413120ab2 100644
--- a/src/public/app/widgets/dialogs/delete_notes.js
+++ b/src/public/app/widgets/dialogs/delete_notes.js
@@ -97,7 +97,7 @@ export default class DeleteNotesDialog extends BasicWidget {
this.resolve({
proceed: true,
- deleteAllClones: this.isDeleteAllClonesChecked(),
+ deleteAllClones: this.forceDeleteAllClones || this.isDeleteAllClonesChecked(),
eraseNotes: this.isEraseNotesChecked()
});
});
@@ -108,7 +108,7 @@ export default class DeleteNotesDialog extends BasicWidget {
async renderDeletePreview() {
const response = await server.post('delete-notes-preview', {
branchIdsToDelete: this.branchIds,
- deleteAllClones: this.isDeleteAllClonesChecked()
+ deleteAllClones: this.forceDeleteAllClones || this.isDeleteAllClonesChecked()
});
this.$deleteNotesList.empty();
@@ -143,14 +143,18 @@ export default class DeleteNotesDialog extends BasicWidget {
}
}
- async showDeleteNotesDialogEvent({branchIdsToDelete, callback}) {
+ async showDeleteNotesDialogEvent({branchIdsToDelete, callback, forceDeleteAllClones}) {
this.branchIds = branchIdsToDelete;
+ this.forceDeleteAllClones = forceDeleteAllClones;
await this.renderDeletePreview();
utils.openDialog(this.$widget);
- this.$deleteAllClones.prop("checked", false);
+ this.$deleteAllClones
+ .prop("checked", !!forceDeleteAllClones)
+ .prop("disabled", !!forceDeleteAllClones);
+
this.$eraseNotes.prop("checked", false);
this.resolve = callback;
diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js
index 3f3ba7948..dba1fc018 100644
--- a/src/public/app/widgets/note_tree.js
+++ b/src/public/app/widgets/note_tree.js
@@ -946,7 +946,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
if (this.noteContext
&& this.noteContext.notePath
- && !this.noteContext.note.isDeleted
+ && !this.noteContext.note?.isDeleted
&& !this.noteContext.notePath.includes("root/hidden")
) {
const newActiveNode = await this.getNodeFromPath(this.noteContext.notePath);