wip: split shared ops

This commit is contained in:
Matteo Pagliazzi
2016-03-07 23:02:42 +01:00
parent 8437c21a51
commit eeebe4c342
55 changed files with 1925 additions and 1634 deletions

View File

@@ -0,0 +1,27 @@
import taskDefaults from '../libs/taskDefaults';
import i18n from '../i18n';
module.exports = function(user, req, cb) {
var task;
task = api.taskDefaults(req.body);
if (user.tasks[task.id] != null) {
return typeof cb === "function" ? cb({
code: 409,
message: i18n.t('messageDuplicateTaskID', req.language)
}) : void 0;
}
user[task.type + "s"].unshift(task);
if (user.preferences.newTaskEdit) {
task._editing = true;
}
if (user.preferences.tagsCollapsed) {
task._tags = true;
}
if (!user.preferences.advancedCollapsed) {
task._advanced = true;
}
if (typeof cb === "function") {
cb(null, task);
}
return task;
};