From b6b97601277aef7657b57e84fa3147be92cc7021 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Thu, 4 Dec 2014 16:10:11 +0200 Subject: avoid popping the confirm dialog for temp nodes removal the change is a one liner hidden in 24 lines of refactoring :/ --- src/model/graph.js | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'src/model') 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) { -- cgit v1.3.1