summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2015-07-30 12:28:04 +0300
committerAlon Levy <alon@pobox.com>2015-07-30 12:28:04 +0300
commita2a56abbd27417e64ae243b9224b89c24c4c406a (patch)
tree5b729ef6e0e9d0a018db22f4147bc22fefdf042d
parentafbb4a1580d563d3f4639114b241adfe4ae93740 (diff)
client: node position storing: change key format to use underscores, more cypher friendly
-rw-r--r--src/client/model/graph.js14
-rw-r--r--src/client/view/graph_view.js4
2 files changed, 14 insertions, 4 deletions
diff --git a/src/client/model/graph.js b/src/client/model/graph.js
index 2c2bd89a..a6f4f3a4 100644
--- a/src/client/model/graph.js
+++ b/src/client/model/graph.js
@@ -631,14 +631,24 @@ function Graph(spec) {
rz_api_backend.commit_diff__attr(attr_diff, on_ajax_success, on_ajax_error);
};
+ function layout_x_key(layout_name) {
+ return 'layouts_' + layout_name + '_x';
+ }
+ this.layout_x_key = layout_x_key;
+
+ function layout_y_key(layout_name) {
+ return 'layouts_' + layout_name + '_y';
+ }
+ this.layout_y_key = layout_y_key;
+
/**
* Do an attribute commit with x, y for the current layout
*/
this.nodes__update_positions = function(layout_name) {
// TODO: fix when attribute diff supports nested keys to use:
// layout.<layout_name>.{x,y}
- var x_key = 'layouts.' + layout_name + '.x',
- y_key = 'layouts.' + layout_name + '.y';
+ var x_key = layout_x_key(layout_name),
+ y_key = layout_y_key(layout_name);
// commit x, y to layout
_.values(id_to_node_map).forEach(function (node) {
diff --git a/src/client/view/graph_view.js b/src/client/view/graph_view.js
index 687b766f..94bb13ff 100644
--- a/src/client/view/graph_view.js
+++ b/src/client/view/graph_view.js
@@ -206,8 +206,8 @@ function GraphView(spec) {
graph.diffBus.onValue(function (diff) {
var relayout = !temporary && (false === model_diff.is_attr_diff(diff)),
have_position = 0,
- layout_x_key = 'layouts.' + layout.name + '.x',
- layout_y_key = 'layouts.' + layout.name + '.y';
+ layout_x_key = graph.layout_x_key(layout.name),
+ layout_y_key = graph.layout_y_key(layout.name);
// copy position from diff based on current layout
if (layout.name && diff.node_set_add) {