|
@ -422,12 +422,23 @@ class EdgesHandler { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Scan for missing nodes and remove corresponding edges, if any. |
|
|
|
|
|
* |
|
|
|
|
|
* There is no direct relation between the nodes and the edges DataSet, |
|
|
* There is no direct relation between the nodes and the edges DataSet, |
|
|
* so the right place to do call this is in the handler for event `_dataUpdated`. |
|
|
* so the right place to do call this is in the handler for event `_dataUpdated`. |
|
|
*/ |
|
|
*/ |
|
|
_updateState() { |
|
|
_updateState() { |
|
|
|
|
|
|
|
|
|
|
|
this._addMissingEdges(); |
|
|
|
|
|
|
|
|
|
|
|
this._removeInvalidEdges(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Scan for missing nodes and remove corresponding edges, if any. |
|
|
|
|
|
* @private |
|
|
|
|
|
*/ |
|
|
|
|
|
_removeInvalidEdges() { |
|
|
|
|
|
|
|
|
let edgesToDelete = []; |
|
|
let edgesToDelete = []; |
|
|
|
|
|
|
|
|
util.forEach(this.body.edges, (edge, id) => { |
|
|
util.forEach(this.body.edges, (edge, id) => { |
|
@ -447,6 +458,27 @@ class EdgesHandler { |
|
|
|
|
|
|
|
|
this.remove(edgesToDelete, false); |
|
|
this.remove(edgesToDelete, false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* add all edges from dataset that are not in the cached state |
|
|
|
|
|
* @private |
|
|
|
|
|
*/ |
|
|
|
|
|
_addMissingEdges() { |
|
|
|
|
|
|
|
|
|
|
|
let edges = this.body.edges; |
|
|
|
|
|
let edgesData = this.body.data.edges; |
|
|
|
|
|
let addIds = []; |
|
|
|
|
|
|
|
|
|
|
|
edgesData.forEach((edgeData, edgeId) => { |
|
|
|
|
|
let edge = edges[edgeId]; |
|
|
|
|
|
if(edge===undefined) |
|
|
|
|
|
{ |
|
|
|
|
|
addIds.push(edgeId); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.add(addIds,true); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export default EdgesHandler; |
|
|
export default EdgesHandler; |