2016-03-07 22:02:42 +00:00
|
|
|
import taskDefaults from '../libs/taskDefaults';
|
|
|
|
|
|
2016-04-03 19:50:32 +00:00
|
|
|
// TODO move to client since it's only used there?
|
|
|
|
|
|
|
|
|
|
module.exports = function addTask (user, req = {body: {}}) {
|
|
|
|
|
let task = taskDefaults(req.body);
|
|
|
|
|
user.tasksOrder[`${task.type}s`].unshift(task._id);
|
2016-05-10 04:31:34 +00:00
|
|
|
user[`${task.type}s`].unshift(task);
|
2016-04-03 19:50:32 +00:00
|
|
|
|
2016-03-07 22:02:42 +00:00
|
|
|
if (user.preferences.newTaskEdit) {
|
|
|
|
|
task._editing = true;
|
|
|
|
|
}
|
2016-04-03 19:50:32 +00:00
|
|
|
|
2016-03-07 22:02:42 +00:00
|
|
|
if (user.preferences.tagsCollapsed) {
|
|
|
|
|
task._tags = true;
|
|
|
|
|
}
|
2016-04-03 19:50:32 +00:00
|
|
|
|
2016-03-07 22:02:42 +00:00
|
|
|
if (!user.preferences.advancedCollapsed) {
|
|
|
|
|
task._advanced = true;
|
|
|
|
|
}
|
2016-04-03 19:50:32 +00:00
|
|
|
|
2016-03-07 22:02:42 +00:00
|
|
|
return task;
|
|
|
|
|
};
|