fix node data relation and link nodes between them
This commit is contained in:
+13
-4
@@ -35,18 +35,26 @@ export default {
|
|||||||
const stateNode = node.id in state.nodes ? state.nodes[node.id] : undefined
|
const stateNode = node.id in state.nodes ? state.nodes[node.id] : undefined
|
||||||
// FIXME UPDATE AFTER DB MAJ
|
// FIXME UPDATE AFTER DB MAJ
|
||||||
if (node.variant === null || Array.isArray(node.variant)) {
|
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) {
|
if (node.type) {
|
||||||
node.type = node.type === 'texte' ? 'Textref' : 'Textprod'
|
node.type = node.type === 'texte' ? 'ref' : 'prod'
|
||||||
}
|
}
|
||||||
// FIXME REMOVE AFTER DB MAJ
|
// FIXME REMOVE AFTER DB MAJ
|
||||||
for (const relation of RELATIONS) {
|
for (const relation of RELATIONS) {
|
||||||
if (relation in node && node[relation]) {
|
if (relation in node && node[relation]) {
|
||||||
node[relation].forEach(subNode => {
|
node[relation] = node[relation].map(subNode => {
|
||||||
subNode.variant = subNode.variant !== null ? ID_VARIANTS[subNode.variant[0].id] : 'black'
|
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) {
|
if (!stateNode || stateNode.dataLevel < dataLevel) {
|
||||||
node.dataLevel = dataLevel
|
node.dataLevel = dataLevel
|
||||||
@@ -107,6 +115,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getters: {
|
getters: {
|
||||||
|
allNodes: state => state.nodes,
|
||||||
// Args getters
|
// Args getters
|
||||||
nodes: state => ids => ids.map(id => state.nodes[id]),
|
nodes: state => ids => ids.map(id => state.nodes[id]),
|
||||||
node: state => id => state.nodes[id]
|
node: state => id => state.nodes[id]
|
||||||
|
|||||||
Reference in New Issue
Block a user