|
@@ -31,23 +31,21 @@ export default {
|
|
|
},
|
|
|
|
|
|
'ADD_NODES' (state, [nodes, dataLevel]) {
|
|
|
- for (const node of nodes) {
|
|
|
+ function addNode (node, level) {
|
|
|
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] : 'dark'
|
|
|
}
|
|
|
if (node.type) {
|
|
|
- node.type = node.type === 'texte' ? 'ref' : 'prod'
|
|
|
+ node.type = node.type === 'Textref' ? 'ref' : 'prod'
|
|
|
}
|
|
|
- // FIXME REMOVE AFTER DB MAJ
|
|
|
+
|
|
|
for (const relation of RELATIONS) {
|
|
|
if (relation in node && node[relation]) {
|
|
|
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)
|
|
|
+ addNode(subNode, -1)
|
|
|
}
|
|
|
return state.nodes[subNode.id]
|
|
|
})
|
|
@@ -56,10 +54,34 @@ export default {
|
|
|
node[relation] = []
|
|
|
}
|
|
|
}
|
|
|
- if (!stateNode || stateNode.dataLevel < dataLevel) {
|
|
|
- node.dataLevel = dataLevel
|
|
|
+
|
|
|
+ if (node.notes) {
|
|
|
+ node.notes.forEach(note => {
|
|
|
+ if (note.links && note.links.length) {
|
|
|
+ note.links = note.links.map(link => {
|
|
|
+ if (!(link.id in state.nodes) || state.nodes[link.id].dataLevel < 1) {
|
|
|
+ addNode(link, -1)
|
|
|
+ }
|
|
|
+ return state.nodes[link.id]
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!stateNode || stateNode.dataLevel < level) {
|
|
|
+ node.dataLevel = level
|
|
|
}
|
|
|
- Vue.set(state.nodes, node.id, stateNode ? { ...stateNode, ...node } : node)
|
|
|
+ if (stateNode === undefined) {
|
|
|
+ Vue.set(state.nodes, node.id, node)
|
|
|
+ } else {
|
|
|
+ for (const key in node) {
|
|
|
+ Vue.set(state.nodes[node.id], key, node[key])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (const node of nodes) {
|
|
|
+ addNode(node, dataLevel)
|
|
|
}
|
|
|
}
|
|
|
},
|