fix: Correct checklist on client

Closes #7207
This commit is contained in:
Blade Barringer
2016-05-13 22:05:00 -05:00
parent 1fd7df7521
commit 0a8b8236c1
2 changed files with 18 additions and 16 deletions

View File

@@ -2,25 +2,24 @@ 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 (req.body.reminders) {
task.reminders = req.body.reminders;
delete req.body.reminders;
if (body.reminders) {
task.reminders = body.reminders;
}
// If checklist is updated -> replace the original one
if (req.body.checklist) {
task.checklist = req.body.checklist;
delete req.body.checklist;
if (body.checklist) {
task.checklist = body.checklist;
}
// If tags are updated -> replace the original ones
if (req.body.tags) {
task.tags = req.body.tags;
delete req.body.tags;
if (body.tags) {
task.tags = body.tags;
}
_.merge(task, _.omit(req.body, ['_id', 'id', 'type']));
_.merge(task, _.omit(body, ['_id', 'id', 'type', 'reminders', 'checklist', 'tags']));
return [task];
};