added unhoist button to the tree node + onclick fixes

This commit is contained in:
zadam
2021-02-06 19:58:12 +01:00
parent 0f05d6258e
commit 2a67d9eae2
6 changed files with 167 additions and 192 deletions

View File

@@ -198,9 +198,9 @@ export default class NoteTreeWidget extends TabAwareWidget {
this.$widget = $(TPL);
this.$tree = this.$widget.find('.tree');
this.$tree.on("click", ".unhoist-button", hoistedNoteService.unhoist);
this.$tree.on("click", ".refresh-search-button", e => this.refreshSearch(e));
this.$tree.on("click", ".add-note-button", e => {
this.$tree.on("mousedown", ".unhoist-button", () => hoistedNoteService.unhoist());
this.$tree.on("mousedown", ".refresh-search-button", e => this.refreshSearch(e));
this.$tree.on("mousedown", ".add-note-button", e => {
const node = $.ui.fancytree.getNode(e);
noteCreateService.createNote(node.data.noteId, {
@@ -208,18 +208,12 @@ export default class NoteTreeWidget extends TabAwareWidget {
});
});
this.$tree.on("click", ".enter-workspace-button", e => {
this.$tree.on("mousedown", ".enter-workspace-button", e => {
const node = $.ui.fancytree.getNode(e);
this.triggerCommand('hoistNote', {noteId: node.data.noteId});
});
this.$tree.on("click", ".unhoist-button", e => {
const node = $.ui.fancytree.getNode(e);
this.triggerCommand('unhoist');
});
// fancytree doesn't support middle click so this is a way to support it
this.$tree.on('mousedown', '.fancytree-title', e => {
if (e.which === 2) {
@@ -514,11 +508,20 @@ export default class NoteTreeWidget extends TabAwareWidget {
return;
}
const note = await treeCache.getNote(node.data.noteId);
const activeTabContext = appContext.tabManager.getActiveTabContext();
const $span = $(node.span);
$span.find('.tree-item-button').remove();
const note = await treeCache.getNote(node.data.noteId);
if (activeTabContext && activeTabContext.hoistedNoteId === note.noteId && note.noteId !== 'root') {
const $unhoistButton = $('<span class="tree-item-button unhoist-button bx bx-door-open" title="Unhoist"></span>');
$unhoistButton.on('click', () => alert("bebe"));
$span.append($unhoistButton);
}
if (note.hasLabel('workspace')) {
const $enterWorkspaceButton = $('<span class="tree-item-button enter-workspace-button bx bx-door-open" title="Hoist this note (workspace)"></span>');