change tree node icon for selected notes to quickly bring up bulk action dialog

This commit is contained in:
zadam
2022-06-12 13:57:22 +02:00
parent 1bfc5fb77f
commit 4aaa0f8d8c
7 changed files with 31 additions and 123 deletions

View File

@@ -307,7 +307,14 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
const targetType = data.targetType;
const node = data.node;
if (targetType === 'title' || targetType === 'icon') {
if (node.isSelected() && targetType === 'icon') {
this.triggerCommand('openBulkActionsDialog', {
selectedOrActiveNoteIds: this.getSelectedOrActiveNoteIds(node)
});
return false;
}
else if (targetType === 'title' || targetType === 'icon') {
if (event.shiftKey) {
const activeNode = this.getActiveNode();
@@ -540,8 +547,9 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
}
});
},
select: () => {
// TODO
select: (event, {node}) => {
$(node.span).find(".fancytree-custom-icon").attr("title",
node.isSelected() ? "Apply bulk actions on selected notes" : "");
}
});
@@ -1288,6 +1296,15 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
return nodes.map(node => node.data.branchId);
}
/**
* @param {FancytreeNode} node
*/
getSelectedOrActiveNoteIds(node) {
const nodes = this.getSelectedOrActiveNodes(node);
return nodes.map(node => node.data.noteId);
}
async deleteNotesCommand({node}) {
const branchIds = this.getSelectedOrActiveBranchIds(node)
.filter(branchId => !branchId.startsWith('virt-')); // search results can't be deleted