diff --git a/src/components/common/TreeExplorer.vue b/src/components/common/TreeExplorer.vue index 2adaa18dd..2868955df 100644 --- a/src/components/common/TreeExplorer.vue +++ b/src/components/common/TreeExplorer.vue @@ -3,6 +3,7 @@ class="tree-explorer" :class="props.class" v-model:expandedKeys="expandedKeys" + v-model:selectionKeys="selectionKeys" :value="renderedRoots" selectionMode="single" :pt="{ @@ -42,11 +43,12 @@ import type { } from '@/types/treeExplorerTypes' import type { MenuItem, MenuItemCommandEvent } from 'primevue/menuitem' import { useI18n } from 'vue-i18n' -import { useToast } from 'primevue/usetoast' import { useErrorHandling } from '@/hooks/errorHooks' const expandedKeys = defineModel>('expandedKeys') provide('expandedKeys', expandedKeys) +const selectionKeys = defineModel>('selectionKeys') +provide('selectionKeys', selectionKeys) const props = defineProps<{ roots: TreeExplorerNode[] class?: string @@ -91,6 +93,9 @@ const fillNodeInfo = (node: TreeExplorerNode): RenderedTreeExplorerNode => { } } const onNodeContentClick = (e: MouseEvent, node: RenderedTreeExplorerNode) => { + if (node.handleClick) { + node.handleClick(node, e) + } emit('nodeClick', node, e) } const menu = ref(null) diff --git a/src/components/sidebar/tabs/NodeLibrarySidebarTab.vue b/src/components/sidebar/tabs/NodeLibrarySidebarTab.vue index d264e2b5a..fa201a269 100644 --- a/src/components/sidebar/tabs/NodeLibrarySidebarTab.vue +++ b/src/components/sidebar/tabs/NodeLibrarySidebarTab.vue @@ -123,7 +123,17 @@ const renderedRoot = computed>(() => { } }, children, - draggable: node.leaf + draggable: node.leaf, + handleClick: ( + node: RenderedTreeExplorerNode, + e: MouseEvent + ) => { + if (node.leaf) { + app.addNodeOnGraph(node.data, { pos: app.getCanvasCenter() }) + } else { + toggleNodeOnEvent(e, node) + } + } } } return fillNodeInfo(root.value) @@ -164,17 +174,6 @@ const handleSearch = (query: string) => { }) } -const handleNodeClick = ( - node: RenderedTreeExplorerNode, - e: MouseEvent -) => { - if (node.leaf) { - app.addNodeOnGraph(node.data, { pos: app.getCanvasCenter() }) - } else { - toggleNodeOnEvent(e, node) - } -} - const onAddFilter = (filterAndValue: FilterAndValue) => { filters.value.push({ filter: filterAndValue, diff --git a/src/components/sidebar/tabs/nodeLibrary/NodeBookmarkTreeExplorer.vue b/src/components/sidebar/tabs/nodeLibrary/NodeBookmarkTreeExplorer.vue index 608fa1aa9..297ec3ed0 100644 --- a/src/components/sidebar/tabs/nodeLibrary/NodeBookmarkTreeExplorer.vue +++ b/src/components/sidebar/tabs/nodeLibrary/NodeBookmarkTreeExplorer.vue @@ -5,7 +5,6 @@ :roots="renderedBookmarkedRoot.children" :expandedKeys="expandedKeys" :extraMenuItems="extraMenuItems" - @nodeClick="handleNodeClick" >