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 @@
return new RSVP.Queue()
.push(function () {
// Prevent double click
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
}
return gadget.getDeclaredGadget("tableeditor");
})
.push(function (tablegadget) {
......@@ -35,7 +37,9 @@
});
})
.push(function () {
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = false;
}
});
}
......@@ -81,7 +85,17 @@
JSON.stringify(JSON.parse(result_list[0])
.capacity_by_station_spreadsheet),
{ 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 @@
return new RSVP.Queue()
.push(function () {
// Prevent double click
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
}
return gadget.getDeclaredGadget("tableeditor");
})
.push(function (tablegadget) {
......@@ -35,7 +37,9 @@
});
})
.push(function () {
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = false;
}
});
}
......@@ -81,7 +85,17 @@
JSON.stringify(JSON.parse(result_list[0])
.dp_capacity_spreadsheet),
{ 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 @@
return new RSVP.Queue()
.push(function () {
// Prevent double click
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
}
return gadget.getDeclaredGadget("tableeditor");
})
.push(function (tablegadget) {
......@@ -35,7 +37,9 @@
});
})
.push(function () {
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = false;
}
});
}
......@@ -81,7 +85,17 @@
JSON.stringify(JSON.parse(result_list[0])
.dp_route_spreadsheet),
{ 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 @@
<title>Edit table</title>
<script src="../<%= copy.rsvp.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>
......
......@@ -9,7 +9,9 @@
return new RSVP.Queue()
.push(function () {
// Prevent double click
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
}
return gadget.getDeclaredGadget("productionline_graph");
})
.push(function (graph_gadget) {
......@@ -29,7 +31,7 @@
data.nodes = json_graph_data.nodes;
data.edges = json_graph_data.edges;
data.preference = json_graph_data.preferences;
data.preference = json_graph_data.preference;
return gadget.aq_putAttachment({
"_id": gadget.props.jio_key,
......@@ -39,7 +41,9 @@
});
})
.push(function () {
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = false;
}
});
}
......@@ -94,6 +98,13 @@
.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;
......
......@@ -9,7 +9,9 @@
return new RSVP.Queue()
.push(function () {
// Prevent double click
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
}
return gadget.getDeclaredGadget("tableeditor");
})
.push(function (tablegadget) {
......@@ -35,7 +37,9 @@
});
})
.push(function () {
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = false;
}
});
}
......@@ -80,7 +84,17 @@
return result_list[1].render(
JSON.stringify(JSON.parse(result_list[0])
.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 @@
return new RSVP.Queue()
.push(function () {
// Prevent double click
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
}
return gadget.getDeclaredGadget("tableeditor");
})
.push(function (tablegadget) {
......@@ -35,7 +37,9 @@
});
})
.push(function () {
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = false;
}
});
}
......@@ -79,7 +83,17 @@
.push(function (result_list) {
return result_list[1].render(
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 @@
<script src="Input_viewSimulation.js" type="text/javascript"></script>
</head>
<body>
<form class="save_form">
<form class="run_form">
<fieldset>
<div data-gadget-url="../fieldset/index.html"
data-gadget-scope="fieldset"></div>
......
......@@ -76,7 +76,7 @@
return new RSVP.Queue()
.push(function () {
return promiseEventListener(
gadget.props.element.getElementsByClassName("save_form")[0],
gadget.props.element.getElementsByClassName("run_form")[0],
'submit',
false
);
......
......@@ -9,7 +9,9 @@
return new RSVP.Queue()
.push(function () {
// Prevent double click
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
}
return gadget.getDeclaredGadget("tableeditor");
})
.push(function (tablegadget) {
......@@ -35,7 +37,9 @@
});
})
.push(function () {
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = false;
}
});
}
......@@ -79,7 +83,17 @@
.push(function (result_list) {
return result_list[1].render(
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 @@
width: 79.5%;
float: right;
}
// XXX disable save button for now
form.save_form {
display: none;
}
......@@ -11,6 +11,7 @@
<script src="../<%= copy.renderjs.relative_dest %>"></script>
<script src="../<%= curl.jsplumbjs.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">
<div class="window {{class}}"
......
......@@ -77,7 +77,6 @@
return new RSVP.Promise(itsANonResolvableTrap, canceller);
}
function getNodeId(node_container, element_id) {
var node_id;
$.each(node_container, function (k, v) {
......@@ -111,9 +110,10 @@
return 'DreamNode_' + n;
}
function onDataChange() {
//$.publish("Dream.Gui.onDataChange", g.private.getData());
return undefined;
function onDataChange(g) {
g.getData().then(function (data) {
$.publish("Dream.Gui.onDataChange", data);
});
}
function updateConnectionData(gadget, connection, remove, edge_data) {
......@@ -126,7 +126,7 @@
edge_data || {}
];
}
onDataChange();
onDataChange(gadget);
}
// bind to connection/connectionDetached events,
......@@ -202,7 +202,7 @@
}
coordinates[node_id] = coordinate;
gadget.props.preference_container.coordinates = coordinates;
onDataChange();
onDataChange(gadget);
return coordinate;
}
......@@ -283,7 +283,7 @@
// });
// split in 2 methods ? one for events one for manip
onDataChange();
onDataChange(gadget);
draggable(gadget);
}
......@@ -399,7 +399,7 @@
delete gadget.props.edge_container[k];
}
});
onDataChange();
onDataChange(gadget);
}
function updateElementData(gadget, node_id, data) {
......@@ -429,7 +429,7 @@
= gadget.props.preference_container.coordinates[node_id];
delete gadget.props.preference_container.coordinates[node_id];
}
onDataChange();
onDataChange(gadget);
}
// function clearAll(gadget) {
......@@ -642,7 +642,7 @@
box.css("left", absolute_position[0]);
updateNodeStyle(gadget, element.element_id);
draggable(gadget);
onDataChange();
onDataChange(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