Commit 60c7da6b authored by Jérome Perrin's avatar Jérome Perrin Committed by Ioannis Papagiannopoulos

graph editor: (partially) update to new json format

parent 7c11c968
...@@ -15,28 +15,14 @@ ...@@ -15,28 +15,14 @@
return gadget.getDeclaredGadget("productionline_graph"); return gadget.getDeclaredGadget("productionline_graph");
}) })
.push(function (graph_gadget) { .push(function (graph_gadget) {
return graph_gadget.getData(); return graph_gadget.getContent();
})
.push(function (data) {
graph_data = data;
// Always get a fresh version, to prevent deleting spreadsheet & co
return gadget.aq_getAttachment({
"_id": gadget.props.jio_key,
"_attachment": "body.json"
});
}) })
.push(function (body) { .push(function (body) {
var data = JSON.parse(body), console.log("saving", JSON.parse(body));
json_graph_data = JSON.parse(graph_data);
data.nodes = json_graph_data.nodes;
data.edges = json_graph_data.edges;
data.preference = json_graph_data.preference;
return gadget.aq_putAttachment({ return gadget.aq_putAttachment({
"_id": gadget.props.jio_key, "_id": gadget.props.jio_key,
"_attachment": "body.json", "_attachment": "body.json",
"_data": JSON.stringify(data, null, 2), "_data": body, //JSON.stringify(data, null, 2),
"_mimetype": "application/json" "_mimetype": "application/json"
}); });
}) })
......
This diff is collapsed.
...@@ -42,13 +42,14 @@ ...@@ -42,13 +42,14 @@
tools_container.className = 'tools-container'; tools_container.className = 'tools-container';
Object.keys(data.class_definition).forEach(function (key) { Object.keys(data.class_definition).forEach(function (key) {
var _class = data.class_definition[key], tool; var _class = data.class_definition[key], tool;
// XXX "expand" the json schema "allOF" etc
if (_class._class === 'node') { if (_class._class === 'node') {
tool = document.createElement('div'); tool = document.createElement('div');
// XXX maybe allow to configure the class name ? // XXX maybe allow to configure the class name ?
tool.className = "tool " + key; tool.className = "tool " + key;
tool.textContent = _class.name || key; tool.textContent = _class.name || key;
tool.draggable = true; tool.draggable = true;
tool.dataset.class_definition = JSON.stringify(_class); tool.dataset.class_definition = JSON.stringify([key, _class]);
Object.keys(_class.css || {}).forEach(function (k) { Object.keys(_class.css || {}).forEach(function (k) {
tool.style[k] = _class.css[k]; tool.style[k] = _class.css[k];
}); });
......
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