Ability to reorder and edit tasks

This commit is contained in:
yflory
2018-02-15 15:38:39 +01:00
parent 70e014cdfc
commit 54a91f1153
4 changed files with 59 additions and 4 deletions

View File

@@ -77,6 +77,17 @@ define([
if (proxy.data[id]) { delete proxy.data[id]; }
};
/* change the order in the proxy (with a check to make sure that nothing is missing */
var reorder = function (proxy, order) {
var existingOrder = proxy.order.slice().sort();
var newOrder = order.slice().sort();
if (JSON.stringify(existingOrder) === JSON.stringify(newOrder)) {
proxy.order = order.slice();
} else {
console.error("Can't reorder the tasks. Some tasks are missing or added");
}
};
Todo.init = function (proxy) {
var api = {};
initialize(proxy);
@@ -90,6 +101,12 @@ define([
api.remove = function (id) {
return remove(proxy, id);
};
api.getOrder = function () {
return proxy.order.slice();
};
api.reorder = function (order) {
return reorder(proxy, order);
};
return api;
};