Revert "API v3 [WIP] (#6144)"

This reverts commit 28f2e9c356.
This commit is contained in:
Blade Barringer
2016-05-23 07:53:14 -05:00
parent 28f2e9c356
commit 0a7b6b65e7
993 changed files with 12914 additions and 44919 deletions
+17 -19
View File
@@ -1,25 +1,23 @@
import i18n from '../i18n';
import _ from 'lodash';
// From server pass task.toObject() not the task document directly
module.exports = function updateTask (task, req = {}) {
let body = req.body || {};
// If reminders are updated -> replace the original ones
if (body.reminders) {
task.reminders = body.reminders;
module.exports = function(user, req, cb) {
var ref, task;
if (!(task = user.tasks[(ref = req.params) != null ? ref.id : void 0])) {
return typeof cb === "function" ? cb({
code: 404,
message: i18n.t('messageTaskNotFound', req.language)
}) : void 0;
}
// If checklist is updated -> replace the original one
if (body.checklist) {
task.checklist = body.checklist;
_.merge(task, _.omit(req.body, ['checklist', 'reminders', 'id', 'type']));
if (req.body.checklist) {
task.checklist = req.body.checklist;
}
// If tags are updated -> replace the original ones
if (body.tags) {
task.tags = body.tags;
if (req.body.reminders) {
task.reminders = req.body.reminders;
}
_.merge(task, _.omit(body, ['_id', 'id', 'type', 'reminders', 'checklist', 'tags']));
return [task];
if (typeof task.markModified === "function") {
task.markModified('tags');
}
return typeof cb === "function" ? cb(null, task) : void 0;
};