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

update static version

parent 7d22f9be
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
<title>Edit table</title> <title>Edit table</title>
<script src="../lib/rsvp.min.js" type="text/javascript"></script> <script src="../lib/rsvp.min.js" type="text/javascript"></script>
<script src="../lib/renderjs.min.js" type="text/javascript"></script> <script src="../lib/renderjs.min.js" type="text/javascript"></script>
<script src="../lib/pubsub.js" type="text/javascript"></script>
<script src="mixin_promise.js" type="text/javascript"></script> <script src="mixin_promise.js" type="text/javascript"></script>
<script src="Input_viewProductionLine.js" type="text/javascript"></script> <script src="Input_viewProductionLine.js" type="text/javascript"></script>
......
...@@ -45,7 +45,17 @@ ...@@ -45,7 +45,17 @@
return g.getElement().push(function(element) { return g.getElement().push(function(element) {
g.props.element = element; g.props.element = element;
}); });
}).declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareMethod("render", function(options) { }).declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").allowPublicAcquisition("notifyDataChanged", function() {
// We are notified by an included gadget that the data has changed.
// Here we save automatically. We could mark a dirty flag to warn the
// user if she leaves the page without saving.
// Since we are notified quite often and saving is resource expensive, we
// use this trick to prevent saving too many times
if (this.timeout) {
window.clearTimeout(this.timeout);
}
this.timeout = window.setTimeout(saveGraph.bind(this), 100);
}).declareMethod("render", function(options) {
var jio_key = options.id, gadget = this; var jio_key = options.id, gadget = this;
gadget.props.jio_key = jio_key; gadget.props.jio_key = jio_key;
return new RSVP.Queue().push(function() { return new RSVP.Queue().push(function() {
...@@ -63,13 +73,6 @@ ...@@ -63,13 +73,6 @@
}); });
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
var g = this, graph; var g = this, graph;
// save automatically
window.$.subscribe("Dream.Gui.onDataChange", function() {
if (g.timeout) {
window.clearTimeout(g.timeout);
}
g.timeout = window.setTimeout(saveGraph.bind(g), 100);
});
return g.getDeclaredGadget("productionline_graph").push(function(graph_gadget) { return g.getDeclaredGadget("productionline_graph").push(function(graph_gadget) {
graph = graph_gadget; graph = graph_gadget;
return g.getDeclaredGadget("productionline_toolbox"); return g.getDeclaredGadget("productionline_toolbox");
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
<script src="../lib/renderjs.min.js"></script> <script src="../lib/renderjs.min.js"></script>
<script src="../lib/jquery.jsplumb.min.js"></script> <script src="../lib/jquery.jsplumb.min.js"></script>
<script src="../lib/handlebars.min.js"></script> <script src="../lib/handlebars.min.js"></script>
<script src="../lib/pubsub.js" type="text/javascript"></script>
<script id="node-template" type="text/x-handlebars-template"> <script id="node-template" type="text/x-handlebars-template">
<div class="window {{class}}" <div class="window {{class}}"
......
...@@ -84,18 +84,13 @@ ...@@ -84,18 +84,13 @@
} }
return "DreamNode_" + n; return "DreamNode_" + n;
} }
function onDataChange(g) {
g.getData().then(function(data) {
$.publish("Dream.Gui.onDataChange", data);
});
}
function updateConnectionData(gadget, connection, remove, edge_data) { function updateConnectionData(gadget, connection, remove, edge_data) {
if (remove) { if (remove) {
delete gadget.props.edge_container[connection.id]; delete gadget.props.edge_container[connection.id];
} else { } else {
gadget.props.edge_container[connection.id] = [ getNodeId(gadget.props.node_container, connection.sourceId), getNodeId(gadget.props.node_container, connection.targetId), edge_data || {} ]; gadget.props.edge_container[connection.id] = [ getNodeId(gadget.props.node_container, connection.sourceId), getNodeId(gadget.props.node_container, connection.targetId), edge_data || {} ];
} }
onDataChange(gadget); gadget.notifyDataChanged();
} }
// bind to connection/connectionDetached events, // bind to connection/connectionDetached events,
// and update the list of connections on screen. // and update the list of connections on screen.
...@@ -135,7 +130,7 @@ ...@@ -135,7 +130,7 @@
} }
coordinates[node_id] = coordinate; coordinates[node_id] = coordinate;
gadget.props.preference_container.coordinates = coordinates; gadget.props.preference_container.coordinates = coordinates;
onDataChange(gadget); gadget.notifyDataChanged();
return coordinate; return coordinate;
} }
function draggable(gadget) { function draggable(gadget) {
...@@ -197,7 +192,7 @@ ...@@ -197,7 +192,7 @@
// return undefined; // return undefined;
// }); // });
// split in 2 methods ? one for events one for manip // split in 2 methods ? one for events one for manip
onDataChange(gadget); gadget.notifyDataChanged();
draggable(gadget); draggable(gadget);
} }
function updateNodeStyle(gadget, element_id) { function updateNodeStyle(gadget, element_id) {
...@@ -276,7 +271,7 @@ ...@@ -276,7 +271,7 @@
// 1.1111; // 1.1111;
// setZoom(gadget, zoom_level); // setZoom(gadget, zoom_level);
// gadget.props.preference_container.zoom_level = zoom_level; // gadget.props.preference_container.zoom_level = zoom_level;
// onDataChange(); // gadget.notifyDataChanged();
// redraw(gadget); // redraw(gadget);
// } // }
// function zoom_out(gadget) { // function zoom_out(gadget) {
...@@ -284,7 +279,7 @@ ...@@ -284,7 +279,7 @@
// 0.9; // 0.9;
// setZoom(gadget, zoom_level); // setZoom(gadget, zoom_level);
// gadget.props.preference_container.zoom_level = zoom_level; // gadget.props.preference_container.zoom_level = zoom_level;
// onDataChange(); // gadget.notifyDataChanged();
// redraw(gadget); // redraw(gadget);
// } // }
function removeElement(gadget, node_id) { function removeElement(gadget, node_id) {
...@@ -298,7 +293,7 @@ ...@@ -298,7 +293,7 @@
delete gadget.props.edge_container[k]; delete gadget.props.edge_container[k];
} }
}); });
onDataChange(gadget); gadget.notifyDataChanged();
} }
function updateElementData(gadget, node_id, data) { function updateElementData(gadget, node_id, data) {
var element_id = gadget.props.node_container[node_id].element_id, new_id = data.id; var element_id = gadget.props.node_container[node_id].element_id, new_id = data.id;
...@@ -323,7 +318,7 @@ ...@@ -323,7 +318,7 @@
gadget.props.preference_container.coordinates[new_id] = gadget.props.preference_container.coordinates[node_id]; gadget.props.preference_container.coordinates[new_id] = gadget.props.preference_container.coordinates[node_id];
delete gadget.props.preference_container.coordinates[node_id]; delete gadget.props.preference_container.coordinates[node_id];
} }
onDataChange(gadget); gadget.notifyDataChanged();
} }
// function clearAll(gadget) { // function clearAll(gadget) {
// $.each(gadget.props.node_container, function (node_id) { // $.each(gadget.props.node_container, function (node_id) {
...@@ -363,14 +358,6 @@ ...@@ -363,14 +358,6 @@
// var zoom_level = gadget.props.preference_container.zoom_level || 1.0; // var zoom_level = gadget.props.preference_container.zoom_level || 1.0;
// setZoom(gadget, zoom_level); // setZoom(gadget, zoom_level);
// } // }
// function setGeneralProperties(gadget, properties) {
// gadget.props.general_container = properties;
// onDataChange();
// }
// function updateGeneralProperties(gadget, properties) {
// $.extend(gadget.props.general_container, properties);
// onDataChange();
// }
function openNodeDialog(gadget, element, config_dict) { function openNodeDialog(gadget, element, config_dict) {
var node_id = getNodeId(gadget.props.node_container, element.id), node_data = gadget.props.node_container[node_id], element_type = node_data._class.replace(".", "-"), property_list = config_dict[element_type].property_list || [], node_edit_popup = $(gadget.props.element).find("#popup-edit-template"), fieldset_element, delete_promise; var node_id = getNodeId(gadget.props.node_container, element.id), node_data = gadget.props.node_container[node_id], element_type = node_data._class.replace(".", "-"), property_list = config_dict[element_type].property_list || [], node_edit_popup = $(gadget.props.element).find("#popup-edit-template"), fieldset_element, delete_promise;
if (node_edit_popup.length !== 0) { if (node_edit_popup.length !== 0) {
...@@ -468,7 +455,7 @@ ...@@ -468,7 +455,7 @@
box.css("left", absolute_position[0]); box.css("left", absolute_position[0]);
updateNodeStyle(gadget, element.element_id); updateNodeStyle(gadget, element.element_id);
draggable(gadget); draggable(gadget);
onDataChange(gadget); gadget.notifyDataChanged();
} }
function waitForDragover(gadget) { function waitForDragover(gadget) {
return loopEventListener(gadget.props.main, "dragover", false, function() { return loopEventListener(gadget.props.main, "dragover", false, function() {
...@@ -503,7 +490,7 @@ ...@@ -503,7 +490,7 @@
return new RSVP.Promise(itsANonResolvableTrap, canceller); return new RSVP.Promise(itsANonResolvableTrap, canceller);
} }
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("getConfigurationDict", "getConfigurationDict").ready(function(g) { gadget_klass.declareAcquiredMethod("getConfigurationDict", "getConfigurationDict").declareAcquiredMethod("notifyDataChanged", "notifyDataChanged").ready(function(g) {
g.props.edge_container = {}; g.props.edge_container = {};
g.props.preference_container = {}; g.props.preference_container = {};
g.props.style_attr_list = [ "width", "height", "padding-top", "line-height" ]; g.props.style_attr_list = [ "width", "height", "padding-top", "line-height" ];
...@@ -519,6 +506,7 @@ ...@@ -519,6 +506,7 @@
}); });
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
var g = this, preference = g.props.data.preference !== undefined ? g.props.data.preference : {}, coordinates = preference.coordinates, config; var g = this, preference = g.props.data.preference !== undefined ? g.props.data.preference : {}, coordinates = preference.coordinates, config;
g.notifyDataChanged();
return g.getConfigurationDict().push(function(config_dict) { return g.getConfigurationDict().push(function(config_dict) {
config = config_dict; config = config_dict;
g.props.main = g.props.element.querySelector("#main"); g.props.main = g.props.element.querySelector("#main");
......
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