refactor: move parseElements to graph utils

Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
Braks
2021-11-25 15:21:36 +01:00
parent cf2ded4fc8
commit 5ffeb928ae
3 changed files with 65 additions and 103 deletions
+5 -3
View File
@@ -85,7 +85,8 @@ export default (id: string, preloadedState: FlowState) => {
},
actions: {
setElements(elements) {
this.elements = parseElements(elements, this.getNodes, this.getEdges, this.nodeExtent)
const { nodes, edges } = parseElements(elements, this.getNodes, this.getEdges, this.nodeExtent)
this.elements = [...nodes, ...edges]
},
setUserSelection(mousePos) {
this.selectionActive = true
@@ -173,8 +174,9 @@ export default (id: string, preloadedState: FlowState) => {
this.nodesConnectable = isInteractive
this.elementsSelectable = isInteractive
},
async addElements(elements: Elements) {
this.elements = [...this.elements, ...parseElements(elements, this.getNodes, this.getEdges, this.nodeExtent)]
addElements(elements: Elements) {
const { nodes, edges } = parseElements(elements, this.getNodes, this.getEdges, this.nodeExtent)
this.elements = [...this.elements, ...nodes, ...edges]
},
},
})