From cfee58bde74cd9d13134e49c2c200647358db35b Mon Sep 17 00:00:00 2001 From: axolotle Date: Fri, 11 Jun 2021 20:40:28 +0200 Subject: [PATCH] update LibraryTree with MapZoom --- src/components/nodes/NodeViewHeaderRef.vue | 2 +- src/pages/library/LibraryTree.vue | 155 +++++++++++++++++++-- src/store/modules/library.js | 5 +- src/store/utils.js | 2 + 4 files changed, 148 insertions(+), 16 deletions(-) diff --git a/src/components/nodes/NodeViewHeaderRef.vue b/src/components/nodes/NodeViewHeaderRef.vue index e550590..98d92c2 100644 --- a/src/components/nodes/NodeViewHeaderRef.vue +++ b/src/components/nodes/NodeViewHeaderRef.vue @@ -7,7 +7,7 @@ {{ toCommaList(node.authors) }}, - +
{{ node.edition.map(ed => ed.name).join(' ') }} diff --git a/src/pages/library/LibraryTree.vue b/src/pages/library/LibraryTree.vue index 9c8c149..38136ec 100644 --- a/src/pages/library/LibraryTree.vue +++ b/src/pages/library/LibraryTree.vue @@ -1,35 +1,112 @@ diff --git a/src/store/modules/library.js b/src/store/modules/library.js index 0ac7d6b..727e08e 100644 --- a/src/store/modules/library.js +++ b/src/store/modules/library.js @@ -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: [] } } } } diff --git a/src/store/utils.js b/src/store/utils.js index ec72ffc..50117b0 100644 --- a/src/store/utils.js +++ b/src/store/utils.js @@ -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 => {