mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
allow deleting notes from note actions button, closes #3131
This commit is contained in:
parent
6c39b6f548
commit
cf6330dee6
@ -68,7 +68,7 @@ async function moveToParentNote(branchIdsToMove, newParentBranchId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteNotes(branchIdsToDelete) {
|
async function deleteNotes(branchIdsToDelete, forceDeleteAllClones = false) {
|
||||||
branchIdsToDelete = filterRootNote(branchIdsToDelete);
|
branchIdsToDelete = filterRootNote(branchIdsToDelete);
|
||||||
|
|
||||||
if (branchIdsToDelete.length === 0) {
|
if (branchIdsToDelete.length === 0) {
|
||||||
@ -83,7 +83,7 @@ async function deleteNotes(branchIdsToDelete) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
({proceed, deleteAllClones, eraseNotes} = await new Promise(res =>
|
({proceed, deleteAllClones, eraseNotes} = await new Promise(res =>
|
||||||
appContext.triggerCommand('showDeleteNotesDialog', {branchIdsToDelete, callback: res})));
|
appContext.triggerCommand('showDeleteNotesDialog', {branchIdsToDelete, callback: res, forceDeleteAllClones})));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!proceed) {
|
if (!proceed) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import NoteContextAwareWidget from "../note_context_aware_widget.js";
|
import NoteContextAwareWidget from "../note_context_aware_widget.js";
|
||||||
import utils from "../../services/utils.js";
|
import utils from "../../services/utils.js";
|
||||||
|
import branchService from "../../services/branches.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
<div class="dropdown note-actions">
|
<div class="dropdown note-actions">
|
||||||
@ -30,6 +31,7 @@ const TPL = `
|
|||||||
<a data-trigger-command="openNoteExternally" class="dropdown-item open-note-externally-button"><kbd data-command="openNoteExternally"></kbd> Open note externally</a>
|
<a data-trigger-command="openNoteExternally" class="dropdown-item open-note-externally-button"><kbd data-command="openNoteExternally"></kbd> Open note externally</a>
|
||||||
<a class="dropdown-item import-files-button">Import files</a>
|
<a class="dropdown-item import-files-button">Import files</a>
|
||||||
<a class="dropdown-item export-note-button">Export note</a>
|
<a class="dropdown-item export-note-button">Export note</a>
|
||||||
|
<a class="dropdown-item delete-note-button">Delete note</a>
|
||||||
<a data-trigger-command="printActiveNote" class="dropdown-item print-active-note-button"><kbd data-command="printActiveNote"></kbd> Print note</a>
|
<a data-trigger-command="printActiveNote" class="dropdown-item print-active-note-button"><kbd data-command="printActiveNote"></kbd> Print note</a>
|
||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
@ -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.$widget.on('click', '.dropdown-item', () => this.$widget.find("[data-toggle='dropdown']").dropdown('toggle'));
|
||||||
|
|
||||||
this.$openNoteExternallyButton = this.$widget.find(".open-note-externally-button");
|
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) {
|
refreshWithNote(note) {
|
||||||
|
@ -97,7 +97,7 @@ export default class DeleteNotesDialog extends BasicWidget {
|
|||||||
|
|
||||||
this.resolve({
|
this.resolve({
|
||||||
proceed: true,
|
proceed: true,
|
||||||
deleteAllClones: this.isDeleteAllClonesChecked(),
|
deleteAllClones: this.forceDeleteAllClones || this.isDeleteAllClonesChecked(),
|
||||||
eraseNotes: this.isEraseNotesChecked()
|
eraseNotes: this.isEraseNotesChecked()
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -108,7 +108,7 @@ export default class DeleteNotesDialog extends BasicWidget {
|
|||||||
async renderDeletePreview() {
|
async renderDeletePreview() {
|
||||||
const response = await server.post('delete-notes-preview', {
|
const response = await server.post('delete-notes-preview', {
|
||||||
branchIdsToDelete: this.branchIds,
|
branchIdsToDelete: this.branchIds,
|
||||||
deleteAllClones: this.isDeleteAllClonesChecked()
|
deleteAllClones: this.forceDeleteAllClones || this.isDeleteAllClonesChecked()
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$deleteNotesList.empty();
|
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.branchIds = branchIdsToDelete;
|
||||||
|
this.forceDeleteAllClones = forceDeleteAllClones;
|
||||||
|
|
||||||
await this.renderDeletePreview();
|
await this.renderDeletePreview();
|
||||||
|
|
||||||
utils.openDialog(this.$widget);
|
utils.openDialog(this.$widget);
|
||||||
|
|
||||||
this.$deleteAllClones.prop("checked", false);
|
this.$deleteAllClones
|
||||||
|
.prop("checked", !!forceDeleteAllClones)
|
||||||
|
.prop("disabled", !!forceDeleteAllClones);
|
||||||
|
|
||||||
this.$eraseNotes.prop("checked", false);
|
this.$eraseNotes.prop("checked", false);
|
||||||
|
|
||||||
this.resolve = callback;
|
this.resolve = callback;
|
||||||
|
@ -946,7 +946,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
|
|
||||||
if (this.noteContext
|
if (this.noteContext
|
||||||
&& this.noteContext.notePath
|
&& this.noteContext.notePath
|
||||||
&& !this.noteContext.note.isDeleted
|
&& !this.noteContext.note?.isDeleted
|
||||||
&& !this.noteContext.notePath.includes("root/hidden")
|
&& !this.noteContext.notePath.includes("root/hidden")
|
||||||
) {
|
) {
|
||||||
const newActiveNode = await this.getNodeFromPath(this.noteContext.notePath);
|
const newActiveNode = await this.getNodeFromPath(this.noteContext.notePath);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user