summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2014-11-03 15:15:02 +0200
committerAlon Levy <alon@pobox.com>2014-11-03 15:18:37 +0200
commit7f56972547de767860ceabe42acca453435c8da5 (patch)
tree99ac66f941e71e3c9ac378049386104c5bb02048 /scripts
parent76765291d6a7993a1fc95fb424367a46c12061a8 (diff)
fix _addNodeNoHistory to correctly look for existing nodeswip/id_not_lower_case_name
Diffstat (limited to 'scripts')
-rw-r--r--scripts/model/graph.js20
1 files changed, 12 insertions, 8 deletions
diff --git a/scripts/model/graph.js b/scripts/model/graph.js
index ad4678d0..c8a0e64c 100644
--- a/scripts/model/graph.js
+++ b/scripts/model/graph.js
@@ -36,13 +36,17 @@ function Graph(el) {
this._addNodeNoHistory = function(spec) {
// No history recorded - this is a helper for loading from files / constant graphs
- var id = spec.id || id_generator();
- var node = findNode(id, null);
- var new_node = undefined;
-
+ var node;
+ if (spec.id === undefined) {
+ node = findNodeByName(spec.name, null);
+ } else {
+ if (spec.id !== undefined) {
+ node = findNode(spec.id, null);
+ }
+ }
if (node === undefined) {
- new_node = {
- "id": id,
+ node = {
+ "id": spec.id || id_generator(),
"name": spec.name,
"type": spec.type,
"state": spec.state,
@@ -53,9 +57,9 @@ function Graph(el) {
'x': spec.x,
'y': spec.y,
};
- nodes.push(new_node);
+ nodes.push(node);
}
- return new_node;
+ return node;
}
this.removeNode = function(id, state) {