summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/model/graph.js36
-rw-r--r--src/client/rz_core.js7
2 files changed, 39 insertions, 4 deletions
diff --git a/src/client/model/graph.js b/src/client/model/graph.js
index 063bc3c5..b671671e 100644
--- a/src/client/model/graph.js
+++ b/src/client/model/graph.js
@@ -542,13 +542,45 @@ function Graph() {
}
}
- this.removeLink = function(link) {
+ var linkGetIndexFromId = function(link_id) {
+ for (var i = 0 ; i < links.length ; ++i) {
+ if (links[i].id == link_id) {
+ return i;
+ }
+ }
+ }
+
+ this.removeLink = function(link, on_success, on_error) {
var i;
+ if (link.id === undefined) {
+ console.log('bug: link without an id');
+ }
+
+ function graph_on_success(ret) {
+ var link_id = ret[0][0];
+ links.splice(linkGetIndexFromId(link_id), 1);
+ if (on_success) {
+ on_success();
+ }
+ }
+
for (i = 0 ; i < links.length; ++i) {
if (link.id !== undefined) {
if (link.id === links[i].id) {
- links.splice(i, 1);
+ if (link.state == 'temp') {
+ links.splice(i, 1);
+ if (on_success) {
+ on_success();
+ }
+ } else {
+ if (rz_config.backend_enabled) {
+ var topo_diff = model_diff.new_topo_diff({
+ link_set_rm: [link.id]
+ });
+ rz_api_backend.commit_diff__topo(topo_diff, graph_on_success, on_error);
+ }
+ }
return;
}
} else {
diff --git a/src/client/rz_core.js b/src/client/rz_core.js
index 7006af36..0ab227d8 100644
--- a/src/client/rz_core.js
+++ b/src/client/rz_core.js
@@ -380,9 +380,12 @@ function update_view__graph(no_relayout) {
dst = this.link.__dst;
view.edge_info.on_delete(function () {
- graph.removeLink(that.link);
- update_view__graph(true);
view.edge_info.hide();
+ graph.removeLink(that.link, function() {
+ update_view__graph(true);
+ }, function() {
+ console.log("error: could not remove link");
+ });
});
view.edge_info.show(d);
selection.update([src, dst]);