summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/model/core.js23
-rw-r--r--src/client/view/graph_view.js9
2 files changed, 22 insertions, 10 deletions
diff --git a/src/client/model/core.js b/src/client/model/core.js
index fb037832..ff484daf 100644
--- a/src/client/model/core.js
+++ b/src/client/model/core.js
@@ -47,18 +47,27 @@ define(['util'], function(util) {
}
function init(config){
- if (config['rand_id_generator'] == 'hash') {
+ if (config.rand_id_generator === 'hash') {
random_id = random_id__hash;
}
- if (config['rand_id_generator'] == 'seq') {
+ if (config.rand_id_generator === 'seq') {
random_id = random_id__seq();
}
}
function Node() {
+ Object.defineProperty(this, "x", {
+ set: function (new_x) {
+ console.log('Node ' + this.id + '.x = ' + new_x);
+ this._x = new_x;
+ },
+ get: function () {
+ return this._x;
+ }
+ });
}
Node.prototype.equals = function(other_node){
- return this.id == other_node.id;
+ return this.id === other_node.id;
};
function Link() {
@@ -77,17 +86,17 @@ define(['util'], function(util) {
*/
function create_node_from_spec(node_spec) {
- util.assert(undefined != node_spec.name, 'create_node_from_spec: name missing');
+ util.assert(undefined !== node_spec.name, 'create_node_from_spec: name missing');
var ret = new Node();
- if (undefined != node_spec.id) {
+ if (undefined !== node_spec.id) {
// reuse id if present
__set_obj_id(ret, node_spec.id);
}
// type
- if (undefined == node_spec.type) {
+ if (undefined === node_spec.type) {
console.debug('create_node_from_spec: undefined type, falling back to \'perm\'');
node_spec.type = 'perm';
}
@@ -134,7 +143,7 @@ define(['util'], function(util) {
var ret = create_link_from_spec(src, dst, link_spec);
__set_obj_id(ret, random_id());
return ret;
- }
+ }
/**
* determine if nodes are equal by name
diff --git a/src/client/view/graph_view.js b/src/client/view/graph_view.js
index da0a3435..b3938075 100644
--- a/src/client/view/graph_view.js
+++ b/src/client/view/graph_view.js
@@ -213,15 +213,18 @@ function GraphView(spec) {
if (layout.name && diff.node_set_add) {
diff.node_set_add.forEach(function (node) {
if (node[layout_x_key] && node[layout_y_key]) {
- node.x = node[layout_x_key];
- node.y = node[layout_y_key];
+ node.px = node.x = node[layout_x_key];
+ node.py = node.y = node[layout_y_key];
have_position += 1;
}
});
if (have_position > 0) {
console.log('loading layout last position from database for layout ' + layout.name);
layout__load_graph();
- relayout = false;
+ if (have_position == graph.nodes().length) {
+ console.log('no relayout because diff contains all graph nodes');
+ relayout = false;
+ }
}
}
update_view(relayout);