improve NodeView components and style
This commit is contained in:
@@ -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
@@ -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 }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user