fix node data relation and link nodes between them

This commit is contained in:
axolotle
2021-06-10 14:00:19 +02:00
parent 133897cf26
commit 346a3ffdfe
+13 -4
View File
@@ -35,18 +35,26 @@ export default {
const stateNode = node.id in state.nodes ? state.nodes[node.id] : undefined
// FIXME UPDATE AFTER DB MAJ
if (node.variant === null || Array.isArray(node.variant)) {
node.variant = node.variant !== null ? ID_VARIANTS[node.variant[0].id] : 'black'
node.variant = node.variant !== null ? ID_VARIANTS[node.variant[0].id] : 'dark'
}
if (node.type) {
node.type = node.type === 'texte' ? 'Textref' : 'Textprod'
node.type = node.type === 'texte' ? 'ref' : 'prod'
}
// FIXME REMOVE AFTER DB MAJ
for (const relation of RELATIONS) {
if (relation in node && node[relation]) {
node[relation].forEach(subNode => {
subNode.variant = subNode.variant !== null ? ID_VARIANTS[subNode.variant[0].id] : 'black'
node[relation] = node[relation].map(subNode => {
if (!(subNode.id in state.nodes)) {
subNode.variant = subNode.variant !== null ? ID_VARIANTS[subNode.variant[0].id] : 'black'
subNode.dataLevel = -1
Vue.set(state.nodes, subNode.id, subNode)
}
return state.nodes[subNode.id]
})
}
if (node[relation] === null) {
node[relation] = []
}
}
if (!stateNode || stateNode.dataLevel < dataLevel) {
node.dataLevel = dataLevel
@@ -107,6 +115,7 @@ export default {
},
getters: {
allNodes: state => state.nodes,
// Args getters
nodes: state => ids => ids.map(id => state.nodes[id]),
node: state => id => state.nodes[id]