improve NodeView components and style

This commit is contained in:
axolotle
2021-06-24 16:13:31 +02:00
parent f4d81dffcf
commit a25123f4f9
13 changed files with 54 additions and 71 deletions
+3 -2
View File
@@ -102,8 +102,9 @@ export default {
async 'INIT_LIBRARY_MAP' ({ state, commit, dispatch }) {
const departIds = await dispatch('INIT_LIBRARY')
const departNodes = await dispatch('GET_NODES', { ids: departIds.slice(0, 3), dataLevel: 'partial' })
const relatedIds = getRelatedNodesIds(departNodes)
const ids = departIds.slice(0, 3)
const departNodes = await dispatch('GET_NODES', { ids, dataLevel: 'partial' })
const relatedIds = getRelatedNodesIds(departNodes, ids)
const relatedNodes = await dispatch('GET_NODES', { ids: relatedIds, dataLevel: 'partial' })
return [...departNodes, ...relatedNodes]
},
+10 -1
View File
@@ -58,12 +58,13 @@ export function getUniqueNodesIds (tree) {
}
export function getRelatedNodesIds (nodes) {
export function getRelatedNodesIds (nodes, ignored) {
const ids = new Set()
for (const node of nodes) {
for (const relation of RELATIONS) {
if (relation in node && node[relation]) {
node[relation].forEach(({ id }) => {
if (ignored.includes(id)) return
ids.add(id)
})
}
@@ -137,3 +138,11 @@ export function tagsInNode (tags, nodeTags) {
if (!nodeTags || nodeTags.length === 0) return false
return tags.every(tag => nodeTags.some(nodeTag => nodeTag.name === tag))
}
export function getRelation (node) {
if (node.type === 'prod' && node.parents && node.parents.length) {
return { parentId: node.parents[0].id, childId: node.id }
}
return { parentId: node.id }
}