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

Remove save button. Save data each time it is modified

parent 9d0d47d2
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
// Prevent double click // Prevent double click
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = true; evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
}
return gadget.getDeclaredGadget("tableeditor"); return gadget.getDeclaredGadget("tableeditor");
}) })
.push(function (tablegadget) { .push(function (tablegadget) {
...@@ -35,7 +37,9 @@ ...@@ -35,7 +37,9 @@
}); });
}) })
.push(function () { .push(function () {
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = false; evt.target.getElementsByClassName("ui-btn")[0].disabled = false;
}
}); });
} }
...@@ -81,7 +85,17 @@ ...@@ -81,7 +85,17 @@
JSON.stringify(JSON.parse(result_list[0]) JSON.stringify(JSON.parse(result_list[0])
.capacity_by_station_spreadsheet), .capacity_by_station_spreadsheet),
{ minSpareCols: 1, { minSpareCols: 1,
minSpareRows: 1 } minSpareRows: 1,
onChange: function () {
if (gadget.timeout) {
window.clearTimeout(gadget.timeout);
}
gadget.timeout = window.setTimeout(
saveSpreadsheet.bind(gadget),
100
);
}
}
); );
}); });
}) })
......
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
// Prevent double click // Prevent double click
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = true; evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
}
return gadget.getDeclaredGadget("tableeditor"); return gadget.getDeclaredGadget("tableeditor");
}) })
.push(function (tablegadget) { .push(function (tablegadget) {
...@@ -35,7 +37,9 @@ ...@@ -35,7 +37,9 @@
}); });
}) })
.push(function () { .push(function () {
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = false; evt.target.getElementsByClassName("ui-btn")[0].disabled = false;
}
}); });
} }
...@@ -81,7 +85,17 @@ ...@@ -81,7 +85,17 @@
JSON.stringify(JSON.parse(result_list[0]) JSON.stringify(JSON.parse(result_list[0])
.dp_capacity_spreadsheet), .dp_capacity_spreadsheet),
{ minSpareCols: 1, { minSpareCols: 1,
minSpareRows: 1 } minSpareRows: 1,
onChange: function () {
if (gadget.timeout) {
window.clearTimeout(gadget.timeout);
}
gadget.timeout = window.setTimeout(
saveSpreadsheet.bind(gadget),
100
);
}
}
); );
}); });
}) })
......
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
// Prevent double click // Prevent double click
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = true; evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
}
return gadget.getDeclaredGadget("tableeditor"); return gadget.getDeclaredGadget("tableeditor");
}) })
.push(function (tablegadget) { .push(function (tablegadget) {
...@@ -35,7 +37,9 @@ ...@@ -35,7 +37,9 @@
}); });
}) })
.push(function () { .push(function () {
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = false; evt.target.getElementsByClassName("ui-btn")[0].disabled = false;
}
}); });
} }
...@@ -81,7 +85,17 @@ ...@@ -81,7 +85,17 @@
JSON.stringify(JSON.parse(result_list[0]) JSON.stringify(JSON.parse(result_list[0])
.dp_route_spreadsheet), .dp_route_spreadsheet),
{ minSpareCols: 1, { minSpareCols: 1,
minSpareRows: 1 } minSpareRows: 1,
onChange: function () {
if (gadget.timeout) {
window.clearTimeout(gadget.timeout);
}
gadget.timeout = window.setTimeout(
saveSpreadsheet.bind(gadget),
100
);
}
}
); );
}); });
}) })
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<title>Edit table</title> <title>Edit table</title>
<script src="../<%= copy.rsvp.relative_dest %>" type="text/javascript"></script> <script src="../<%= copy.rsvp.relative_dest %>" type="text/javascript"></script>
<script src="../<%= copy.renderjs.relative_dest %>" type="text/javascript"></script> <script src="../<%= copy.renderjs.relative_dest %>" 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>
......
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
// Prevent double click // Prevent double click
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = true; evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
}
return gadget.getDeclaredGadget("productionline_graph"); return gadget.getDeclaredGadget("productionline_graph");
}) })
.push(function (graph_gadget) { .push(function (graph_gadget) {
...@@ -29,7 +31,7 @@ ...@@ -29,7 +31,7 @@
data.nodes = json_graph_data.nodes; data.nodes = json_graph_data.nodes;
data.edges = json_graph_data.edges; data.edges = json_graph_data.edges;
data.preference = json_graph_data.preferences; data.preference = json_graph_data.preference;
return gadget.aq_putAttachment({ return gadget.aq_putAttachment({
"_id": gadget.props.jio_key, "_id": gadget.props.jio_key,
...@@ -39,7 +41,9 @@ ...@@ -39,7 +41,9 @@
}); });
}) })
.push(function () { .push(function () {
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = false; evt.target.getElementsByClassName("ui-btn")[0].disabled = false;
}
}); });
} }
...@@ -94,6 +98,13 @@ ...@@ -94,6 +98,13 @@
.declareMethod("startService", function () { .declareMethod("startService", function () {
var g = this, var g = this,
graph; 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") return g.getDeclaredGadget("productionline_graph")
.push(function (graph_gadget) { .push(function (graph_gadget) {
graph = graph_gadget; graph = graph_gadget;
......
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
// Prevent double click // Prevent double click
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = true; evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
}
return gadget.getDeclaredGadget("tableeditor"); return gadget.getDeclaredGadget("tableeditor");
}) })
.push(function (tablegadget) { .push(function (tablegadget) {
...@@ -35,7 +37,9 @@ ...@@ -35,7 +37,9 @@
}); });
}) })
.push(function () { .push(function () {
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = false; evt.target.getElementsByClassName("ui-btn")[0].disabled = false;
}
}); });
} }
...@@ -80,7 +84,17 @@ ...@@ -80,7 +84,17 @@
return result_list[1].render( return result_list[1].render(
JSON.stringify(JSON.parse(result_list[0]) JSON.stringify(JSON.parse(result_list[0])
.capacity_by_project_spreadsheet), .capacity_by_project_spreadsheet),
{minSpareRows: 1} { minSpareRows: 1,
onChange: function () {
if (gadget.timeout) {
window.clearTimeout(gadget.timeout);
}
gadget.timeout = window.setTimeout(
saveSpreadsheet.bind(gadget),
100
);
}
}
); );
}); });
}) })
......
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
// Prevent double click // Prevent double click
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = true; evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
}
return gadget.getDeclaredGadget("tableeditor"); return gadget.getDeclaredGadget("tableeditor");
}) })
.push(function (tablegadget) { .push(function (tablegadget) {
...@@ -35,7 +37,9 @@ ...@@ -35,7 +37,9 @@
}); });
}) })
.push(function () { .push(function () {
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = false; evt.target.getElementsByClassName("ui-btn")[0].disabled = false;
}
}); });
} }
...@@ -79,7 +83,17 @@ ...@@ -79,7 +83,17 @@
.push(function (result_list) { .push(function (result_list) {
return result_list[1].render( return result_list[1].render(
JSON.stringify(JSON.parse(result_list[0]).shift_spreadsheet), JSON.stringify(JSON.parse(result_list[0]).shift_spreadsheet),
{ minSpareRows: 1 } { minSpareRows: 1,
onChange: function () {
if (gadget.timeout) {
window.clearTimeout(gadget.timeout);
}
gadget.timeout = window.setTimeout(
saveSpreadsheet.bind(gadget),
100
);
}
}
); );
}); });
}) })
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<script src="Input_viewSimulation.js" type="text/javascript"></script> <script src="Input_viewSimulation.js" type="text/javascript"></script>
</head> </head>
<body> <body>
<form class="save_form"> <form class="run_form">
<fieldset> <fieldset>
<div data-gadget-url="../fieldset/index.html" <div data-gadget-url="../fieldset/index.html"
data-gadget-scope="fieldset"></div> data-gadget-scope="fieldset"></div>
......
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
return promiseEventListener( return promiseEventListener(
gadget.props.element.getElementsByClassName("save_form")[0], gadget.props.element.getElementsByClassName("run_form")[0],
'submit', 'submit',
false false
); );
......
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
// Prevent double click // Prevent double click
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = true; evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
}
return gadget.getDeclaredGadget("tableeditor"); return gadget.getDeclaredGadget("tableeditor");
}) })
.push(function (tablegadget) { .push(function (tablegadget) {
...@@ -35,7 +37,9 @@ ...@@ -35,7 +37,9 @@
}); });
}) })
.push(function () { .push(function () {
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = false; evt.target.getElementsByClassName("ui-btn")[0].disabled = false;
}
}); });
} }
...@@ -79,7 +83,17 @@ ...@@ -79,7 +83,17 @@
.push(function (result_list) { .push(function (result_list) {
return result_list[1].render( return result_list[1].render(
JSON.stringify(JSON.parse(result_list[0]).wip_part_spreadsheet), JSON.stringify(JSON.parse(result_list[0]).wip_part_spreadsheet),
{ minSpareRows: 1 } { minSpareRows: 1,
onChange: function () {
if (gadget.timeout) {
window.clearTimeout(gadget.timeout);
}
gadget.timeout = window.setTimeout(
saveSpreadsheet.bind(gadget),
100
);
}
}
); );
}); });
}) })
......
...@@ -59,3 +59,8 @@ ...@@ -59,3 +59,8 @@
width: 79.5%; width: 79.5%;
float: right; float: right;
} }
// XXX disable save button for now
form.save_form {
display: none;
}
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<script src="../<%= copy.renderjs.relative_dest %>"></script> <script src="../<%= copy.renderjs.relative_dest %>"></script>
<script src="../<%= curl.jsplumbjs.relative_dest %>"></script> <script src="../<%= curl.jsplumbjs.relative_dest %>"></script>
<script src="../<%= copy.handlebars.relative_dest %>"></script> <script src="../<%= copy.handlebars.relative_dest %>"></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}}"
......
...@@ -77,7 +77,6 @@ ...@@ -77,7 +77,6 @@
return new RSVP.Promise(itsANonResolvableTrap, canceller); return new RSVP.Promise(itsANonResolvableTrap, canceller);
} }
function getNodeId(node_container, element_id) { function getNodeId(node_container, element_id) {
var node_id; var node_id;
$.each(node_container, function (k, v) { $.each(node_container, function (k, v) {
...@@ -111,9 +110,10 @@ ...@@ -111,9 +110,10 @@
return 'DreamNode_' + n; return 'DreamNode_' + n;
} }
function onDataChange() { function onDataChange(g) {
//$.publish("Dream.Gui.onDataChange", g.private.getData()); g.getData().then(function (data) {
return undefined; $.publish("Dream.Gui.onDataChange", data);
});
} }
function updateConnectionData(gadget, connection, remove, edge_data) { function updateConnectionData(gadget, connection, remove, edge_data) {
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
edge_data || {} edge_data || {}
]; ];
} }
onDataChange(); onDataChange(gadget);
} }
// bind to connection/connectionDetached events, // bind to connection/connectionDetached events,
...@@ -202,7 +202,7 @@ ...@@ -202,7 +202,7 @@
} }
coordinates[node_id] = coordinate; coordinates[node_id] = coordinate;
gadget.props.preference_container.coordinates = coordinates; gadget.props.preference_container.coordinates = coordinates;
onDataChange(); onDataChange(gadget);
return coordinate; return coordinate;
} }
...@@ -283,7 +283,7 @@ ...@@ -283,7 +283,7 @@
// }); // });
// split in 2 methods ? one for events one for manip // split in 2 methods ? one for events one for manip
onDataChange(); onDataChange(gadget);
draggable(gadget); draggable(gadget);
} }
...@@ -399,7 +399,7 @@ ...@@ -399,7 +399,7 @@
delete gadget.props.edge_container[k]; delete gadget.props.edge_container[k];
} }
}); });
onDataChange(); onDataChange(gadget);
} }
function updateElementData(gadget, node_id, data) { function updateElementData(gadget, node_id, data) {
...@@ -429,7 +429,7 @@ ...@@ -429,7 +429,7 @@
= gadget.props.preference_container.coordinates[node_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(); onDataChange(gadget);
} }
// function clearAll(gadget) { // function clearAll(gadget) {
...@@ -642,7 +642,7 @@ ...@@ -642,7 +642,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(); onDataChange(gadget);
} }
function waitForDragover(gadget) { function waitForDragover(gadget) {
......
/*global jQuery */
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011
* http://benalman.com/
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function ($) {
"use strict";
var o = $({});
$.subscribe = function () {
o.on.apply(o, arguments);
};
$.unsubscribe = function () {
o.off.apply(o, arguments);
};
$.publish = function () {
o.trigger.apply(o, arguments);
};
}(jQuery));
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