summaryrefslogtreecommitdiff
path: root/src/client/model/graph.js
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2015-02-25 00:22:53 +0200
committerAlon Levy <alon@pobox.com>2015-02-25 00:22:53 +0200
commit64324f317b6fbd9a1b636b0b21e123155f8153d4 (patch)
treee9796eb67a99133b49d2151a0034b180c364f0ad /src/client/model/graph.js
parent717200a13ce38ad113620a092f786e9b1ea6ee85 (diff)
client: selection tools: add link nodes in fan
Diffstat (limited to 'src/client/model/graph.js')
-rw-r--r--src/client/model/graph.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/client/model/graph.js b/src/client/model/graph.js
index c7e255ec..4feb8a52 100644
--- a/src/client/model/graph.js
+++ b/src/client/model/graph.js
@@ -542,6 +542,21 @@ function Graph(spec) {
this.commit_and_tx_diff__topo(topo_diff);
}
+ /**
+ * links the first node in the list to the rest of the list.
+ */
+ var nodes__link_fan = function(node_ids) {
+ util.assert(node_ids.length > 1); // strictly speaking we can also treat 1 as correct usage
+ var src_id = node_ids[0],
+ src_node = find_node__by_id(src_id),
+ added_links = node_ids.slice(1).map(function (tgt_id) {
+ return model_core.create_link__set_random_id(src_node, find_node__by_id(tgt_id),
+ {name: 'link'});
+ });
+ commit_and_tx_diff__topo(model_diff.new_topo_diff({link_set_add: added_links}));
+ };
+ this.nodes__link_fan = nodes__link_fan;
+
var nodes__merge = function(node_ids) {
util.assert(node_ids.length > 1); // strictly speaking we can also treat 1 as correct usage
var merged = _.rest(node_ids);
@@ -570,7 +585,7 @@ function Graph(spec) {
link_set_add: added_links,
node_id_set_rm: merged});
commit_and_tx_diff__topo(topo_diff);
- }
+ };
this.nodes__merge = nodes__merge;
var _remove_link_set = function(link_id_set) {