update LibraryTree with MapZoom

This commit is contained in:
axolotle
2021-06-11 20:40:28 +02:00
parent 56e1c81aef
commit cfee58bde7
4 changed files with 148 additions and 16 deletions
+2 -3
View File
@@ -177,7 +177,7 @@ export default {
})
},
activeNodes: (state) => {
activeNodes: state => {
if (!state.nodebook) return []
return state.nodebook.reduce((acc, ids) => [...acc, ...ids], [])
},
@@ -218,8 +218,7 @@ export default {
},
nodeTree: (state, rootState) => {
if (state.nodeDepartId === undefined) return
return state.trees[state.nodeDepartId]
return state.trees[state.nodeDepartId] || { nodes: [], links: [] }
}
}
}
+2
View File
@@ -92,6 +92,8 @@ export function buildTree (treeData, nodesData) {
if (!uniqueIds.includes(node.id)) {
uniqueIds.push(node.id)
node.data = nodesData.find(n => n.id === node.id)
// Add `x` and `y` keys so Vue can update on these values updates
Object.assign(node, { x: undefined, y: undefined })
nodes.push(node)
if (node.children) {
node.children.forEach(child => {