Commit dffb297b authored by Jérome Perrin's avatar Jérome Perrin

do not use "node_container"

parent 72760be8
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
var n = 1, var n = 1,
class_def = gadget.props.data.class_definition[element._class], class_def = gadget.props.data.class_definition[element._class],
id = class_def.short_id || element._class; id = class_def.short_id || element._class;
while (gadget.props.node_container[id + n] !== undefined) { while (gadget.props.data.graph.node[id + n] !== undefined) {
n += 1; n += 1;
} }
return id + n; return id + n;
...@@ -206,7 +206,7 @@ ...@@ -206,7 +206,7 @@
}; };
} }
gadget.props.node_container[node_id].coordinate = coordinate; gadget.props.data.graph.node[node_id].coordinate = coordinate;
gadget.notifyDataChanged(); gadget.notifyDataChanged();
return coordinate; return coordinate;
} }
...@@ -353,7 +353,7 @@ ...@@ -353,7 +353,7 @@
$(gadget.props.element).find("#" + element_id) $(gadget.props.element).find("#" + element_id)
); );
$(gadget.props.element).find("#" + element_id).remove(); $(gadget.props.element).find("#" + element_id).remove();
delete gadget.props.node_container[node_id]; delete gadget.props.data.graph.node[node_id];
$.each(gadget.props.edge_container, function (k, v) { $.each(gadget.props.edge_container, function (k, v) {
if (node_id === v[0] || node_id === v[1]) { if (node_id === v[0] || node_id === v[1]) {
...@@ -368,19 +368,18 @@ ...@@ -368,19 +368,18 @@
// XXX should probably not use data.data // XXX should probably not use data.data
var element_id = gadget.props.node_id_to_dom_element_id[node_id], var element_id = gadget.props.node_id_to_dom_element_id[node_id],
new_id = data.id; new_id = data.id;
console.log('ued', node_id, data);
if (data.data.name) { if (data.data.name) {
$(gadget.props.element).find("#" + element_id).text(data.data.name) $(gadget.props.element).find("#" + element_id).text(data.data.name)
.append('<div class="ep"></div></div>'); .append('<div class="ep"></div></div>');
gadget.props.node_container[node_id].name = data.data.name; gadget.props.data.graph.node[node_id].name = data.data.name;
} }
delete data.id; delete data.id;
$.extend(gadget.props.node_container[node_id], data.data); $.extend(gadget.props.data.graph.node[node_id], data.data);
if (new_id && new_id !== node_id) { if (new_id && new_id !== node_id) {
gadget.props.node_container[new_id] gadget.props.data.graph.node[new_id]
= gadget.props.node_container[node_id]; = gadget.props.data.graph.node[node_id];
delete gadget.props.node_container[node_id]; delete gadget.props.data.graph.node[node_id];
delete gadget.props.node_container[new_id].id; delete gadget.props.data.graph.node[new_id].id;
$.each(gadget.props.edge_container, function (k, v) { $.each(gadget.props.edge_container, function (k, v) {
if (v[0] === node_id) { if (v[0] === node_id) {
v[0] = new_id; v[0] = new_id;
...@@ -444,7 +443,7 @@ ...@@ -444,7 +443,7 @@
// TODO: remove class_definition from this function and callees signature // TODO: remove class_definition from this function and callees signature
function openNodeDialog(gadget, element, class_definition) { function openNodeDialog(gadget, element, class_definition) {
var node_id = getNodeId(gadget, element.id), var node_id = getNodeId(gadget, element.id),
node_data = gadget.props.node_container[node_id], node_data = gadget.props.data.graph.node[node_id],
node_edit_popup = $(gadget.props.element).find('#popup-edit-template'), node_edit_popup = $(gadget.props.element).find('#popup-edit-template'),
schema = expandSchema(class_definition, gadget.props.data), schema = expandSchema(class_definition, gadget.props.data),
fieldset_element, fieldset_element,
...@@ -549,7 +548,7 @@ ...@@ -549,7 +548,7 @@
gadget.props.node_id_to_dom_element_id[node_id] = dom_element_id; gadget.props.node_id_to_dom_element_id[node_id] = dom_element_id;
node_data.name = node_data.name || class_definition.name; node_data.name = node_data.name || class_definition.name;
gadget.props.node_container[node_id] = node_data; gadget.props.data.graph.node[node_id] = node_data;
if (coordinate === undefined) { if (coordinate === undefined) {
coordinate = {top: 0, left: 0} coordinate = {top: 0, left: 0}
...@@ -660,7 +659,6 @@ ...@@ -660,7 +659,6 @@
.declareMethod('render', function (data) { .declareMethod('render', function (data) {
this.props.data = JSON.parse(data); this.props.data = JSON.parse(data);
this.props.node_container = this.props.data.graph.node;
this.props.jsplumb_instance = jsPlumb.getInstance(); this.props.jsplumb_instance = jsPlumb.getInstance();
}) })
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment