diff options
| author | Alon Levy <alon@pobox.com> | 2014-12-04 16:10:11 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-12-04 16:10:16 +0200 |
| commit | b6b97601277aef7657b57e84fa3147be92cc7021 (patch) | |
| tree | 223641682be92f1bee7972472e54bc682770448a /src | |
| parent | cc4955180003fa8eaae949af00a29ef48f074489 (diff) | |
avoid popping the confirm dialog for temp nodes removal
the change is a one liner hidden in 24 lines of refactoring :/
Diffstat (limited to 'src')
| -rw-r--r-- | src/model/graph.js | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/src/model/graph.js b/src/model/graph.js index 5efab353..5268a007 100644 --- a/src/model/graph.js +++ b/src/model/graph.js @@ -298,12 +298,15 @@ function Graph() { this.editLink = function(src_id, dst_id, newname, newstate) { var link = findLink(src_id, dst_id, newname); - if (link !== undefined) { - link.name = newname; - if (newstate !== undefined) { - link.state = newstate; - } + + if (link === undefined) { + return; + } + link.name = newname; + if (newstate !== undefined) { + link.state = newstate; } + rz_bus.names.push([newname]); } this.editLinkTarget = function(src_id, dst_id, newTarget) { @@ -331,24 +334,26 @@ function Graph() { var index = findNode(id, null); var acceptReplace=true; - if ((index !== undefined)) { - if (index2 !== undefined) { - acceptReplace = confirm('"' + index2.name + '" will replace "' + index.name + '", are you sure?'); - if (acceptReplace){ - for (var i = 0; i < links.length; i++) { - if (links[i].__src === index) { - links[i].__src = index2; - } - if (links[i].__dst === index) { - links[i].__dst = index2; - } + if (index === undefined) { + return; + } + if (index2 !== undefined && index.state !== 'temp') { + acceptReplace = confirm('"' + index2.name + '" will replace "' + index.name + '", are you sure?'); + if (acceptReplace){ + for (var i = 0; i < links.length; i++) { + if (links[i].__src === index) { + links[i].__src = index2; + } + if (links[i].__dst === index) { + links[i].__dst = index2; } - this.removeNode(index.id,null); } - } else { - index.name = new_name; + this.removeNode(index.id,null); } + } else { + index.name = new_name; } + rz_bus.names.push([new_name]); } this.editDates = function(id, type, start, end) { |
