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

update static version

parent 7d22f9be
......@@ -6,8 +6,6 @@
<title>Edit table</title>
<script src="../lib/rsvp.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="Input_viewProductionLine.js" type="text/javascript"></script>
......
......@@ -45,7 +45,17 @@
return g.getElement().push(function(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;
gadget.props.jio_key = jio_key;
return new RSVP.Queue().push(function() {
......@@ -63,13 +73,6 @@
});
}).declareMethod("startService", function() {
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) {
graph = graph_gadget;
return g.getDeclaredGadget("productionline_toolbox");
......
......@@ -11,7 +11,6 @@
<script src="../lib/renderjs.min.js"></script>
<script src="../lib/jquery.jsplumb.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">
<div class="window {{class}}"
......
......@@ -84,18 +84,13 @@
}
return "DreamNode_" + n;
}
function onDataChange(g) {
g.getData().then(function(data) {
$.publish("Dream.Gui.onDataChange", data);
});
}
function updateConnectionData(gadget, connection, remove, edge_data) {
if (remove) {
delete gadget.props.edge_container[connection.id];
} else {
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,
// and update the list of connections on screen.
......@@ -135,7 +130,7 @@
}
coordinates[node_id] = coordinate;
gadget.props.preference_container.coordinates = coordinates;
onDataChange(gadget);
gadget.notifyDataChanged();
return coordinate;
}
function draggable(gadget) {
......@@ -197,7 +192,7 @@
// return undefined;
// });
// split in 2 methods ? one for events one for manip
onDataChange(gadget);
gadget.notifyDataChanged();
draggable(gadget);
}
function updateNodeStyle(gadget, element_id) {
......@@ -276,7 +271,7 @@
// 1.1111;
// setZoom(gadget, zoom_level);
// gadget.props.preference_container.zoom_level = zoom_level;
// onDataChange();
// gadget.notifyDataChanged();
// redraw(gadget);
// }
// function zoom_out(gadget) {
......@@ -284,7 +279,7 @@
// 0.9;
// setZoom(gadget, zoom_level);
// gadget.props.preference_container.zoom_level = zoom_level;
// onDataChange();
// gadget.notifyDataChanged();
// redraw(gadget);
// }
function removeElement(gadget, node_id) {
......@@ -298,7 +293,7 @@
delete gadget.props.edge_container[k];
}
});
onDataChange(gadget);
gadget.notifyDataChanged();
}
function updateElementData(gadget, node_id, data) {
var element_id = gadget.props.node_container[node_id].element_id, new_id = data.id;
......@@ -323,7 +318,7 @@
gadget.props.preference_container.coordinates[new_id] = gadget.props.preference_container.coordinates[node_id];
delete gadget.props.preference_container.coordinates[node_id];
}
onDataChange(gadget);
gadget.notifyDataChanged();
}
// function clearAll(gadget) {
// $.each(gadget.props.node_container, function (node_id) {
......@@ -363,14 +358,6 @@
// var zoom_level = gadget.props.preference_container.zoom_level || 1.0;
// 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) {
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) {
......@@ -468,7 +455,7 @@
box.css("left", absolute_position[0]);
updateNodeStyle(gadget, element.element_id);
draggable(gadget);
onDataChange(gadget);
gadget.notifyDataChanged();
}
function waitForDragover(gadget) {
return loopEventListener(gadget.props.main, "dragover", false, function() {
......@@ -503,7 +490,7 @@
return new RSVP.Promise(itsANonResolvableTrap, canceller);
}
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.preference_container = {};
g.props.style_attr_list = [ "width", "height", "padding-top", "line-height" ];
......@@ -519,6 +506,7 @@
});
}).declareMethod("startService", function() {
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) {
config = config_dict;
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