Tyler Renelle
2013-12-12 17:32:02 -07:00
parent a5bf3440c8
commit 2956ae0462
2 changed files with 26 additions and 0 deletions
+17
View File
@@ -10927,6 +10927,23 @@ var process=require("__browserify_process");(function() {
});
return typeof cb === "function" ? cb(null, req) : void 0;
},
sortTask: function(req, cb) {
var from, id, task, to, _ref;
id = req.params.id;
_ref = req.query, to = _ref.to, from = _ref.from;
task = user.tasks[id];
if (!task) {
return cb({
code: 404,
message: "No task found."
});
}
if (!((to != null) && (from != null))) {
return cb('?to=__&from=__ are required');
}
user["" + task.type + "s"].splice(to, 0, user["" + task.type + "s"].splice(from, 1)[0]);
return cb(null, req);
},
updateTask: function(req, cb) {
if (!(req.params.id && user.tasks[req.params.id])) {
return typeof cb === "function" ? cb("Task not found") : void 0;
+9
View File
@@ -642,6 +642,15 @@ api.wrap = (user) ->
user.fns.dotSet(k,v)
cb? null, req
sortTask: (req, cb) ->
{id} = req.params
{to, from} = req.query
task = user.tasks[id]
return cb({code:404, message: "No task found."}) unless task
return cb('?to=__&from=__ are required') unless to? and from?
user["#{task.type}s"].splice to, 0, user["#{task.type}s"].splice(from, 1)[0]
cb null, req
updateTask: (req, cb) ->
return cb?("Task not found") unless req.params.id and user.tasks[req.params.id]
_.merge user.tasks[req.params.id], req.body