Client Fixed (#9017)

* fix spacing between rewards and items

* fix rewards description

* rewards cost in bold

* fix gp notifications

* fix dailies gray text

* fix cancel in task edit modal

* tags: use AND not OR for filtering

* fix tasksDefaults so that monthlies can be created correctly

* tags: usable if no task selected, saving checklist and tags saved the one being added without requiting to press enter

* remove tags from tasks when they are deleted

* fix tags removal when multiple tags are deleted and fix tags editing
This commit is contained in:
Matteo Pagliazzi
2017-09-02 18:08:32 +02:00
committed by GitHub
parent c2aaa9b592
commit 0424d214c5
11 changed files with 92 additions and 60 deletions

View File

@@ -285,6 +285,8 @@ api.updateUser = {
async handler (req, res) {
let user = res.locals.user;
let promisesForTagsRemoval = [];
_.each(req.body, (val, key) => {
let purchasable = requiresPurchase[key];
@@ -321,20 +323,26 @@ api.updateUser = {
user.tags.push(Tag.sanitize(t));
});
// Remove from all the tasks TODO test
Tasks.Task.update({
userId: user._id,
}, {
$pull: {
tags: {$in: [removedTagsIds]},
},
}, {multi: true}).exec();
// Remove from all the tasks
// NOTE each tag to remove requires a query
promisesForTagsRemoval = removedTagsIds.map(tagId => {
return Tasks.Task.update({
userId: user._id,
}, {
$pull: {
tags: tagId,
},
}, {multi: true}).exec();
});
} else {
throw new NotAuthorized(res.t('messageUserOperationProtected', { operation: key }));
}
});
await user.save();
await Promise.all([user.save()].concat(promisesForTagsRemoval));
return res.respond(200, user);
},
};