diff options
author | Lauri Ojansivu <x@xet7.org> | 2017-09-01 22:06:17 +0300 |
---|---|---|
committer | Lauri Ojansivu <x@xet7.org> | 2017-09-01 22:06:17 +0300 |
commit | 491a352792238abf58ba9d973b5009bff581f904 (patch) | |
tree | 9830aaed6d7f14361a7ac855b4811c9060bf0bbb | |
parent | ddc21046b9385ac5ce5bbb9a773484fcd056d10c (diff) | |
parent | 8d37a0418aaf2987c2d2bb22f2062ed7cbe9aaef (diff) | |
download | wekan-491a352792238abf58ba9d973b5009bff581f904.tar.gz wekan-491a352792238abf58ba9d973b5009bff581f904.tar.bz2 wekan-491a352792238abf58ba9d973b5009bff581f904.zip |
Merge branch 'GhassenRjab-hotfix/issue-1198' into devel
Fix errors caused by checklist items activities.
Thanks to GhassenRjab and nztqa ! Closes #1198
-rw-r--r-- | CHANGELOG.md | 11 | ||||
-rw-r--r-- | models/checklists.js | 33 |
2 files changed, 32 insertions, 12 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c2896a4..b63c0a13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,17 @@ +# Upcoming Wekan release + +This release fixes the following bugs: + +* [Fix errors caused by checklist items activities](https://github.com/wekan/wekan/pull/1200). + +Thanks to GitHub users GhassenRjab and nztqa for contributions. + # v0.34 2017-08-30 Wekan release This release adds the following new features: -* [Import Trello and Wekan board times of creation of activities](https://github.com/wekan/wekan/pull/1187). +* [Import Trello and Wekan board times of creation of activities](https://github.com/wekan/wekan/pull/1187); +* Newest Wekan is available at Sandstorm App Market. Known issues: diff --git a/models/checklists.js b/models/checklists.js index ab4fe61d..2521412f 100644 --- a/models/checklists.js +++ b/models/checklists.js @@ -164,21 +164,32 @@ if (Meteor.isServer) { // The future is now Checklists.after.update((userId, doc, fieldNames, modifier) => { if (fieldNames.includes('items')) { - Activities.insert({ - userId, - activityType: 'addChecklistItem', - cardId: doc.cardId, - boardId: Cards.findOne(doc.cardId).boardId, - checklistId: doc._id, - checklistItemId: modifier.$addToSet.items._id, - }); + if (modifier.$addToSet) { + Activities.insert({ + userId, + activityType: 'addChecklistItem', + cardId: doc.cardId, + boardId: Cards.findOne(doc.cardId).boardId, + checklistId: doc._id, + checklistItemId: modifier.$addToSet.items._id, + }); + } else if (modifier.$pull) { + const activity = Activities.findOne({ + checklistItemId: modifier.$pull.items._id, + }); + if (activity) { + Activities.remove(activity._id); + } + } } }); Checklists.before.remove((userId, doc) => { - const activity = Activities.findOne({ checklistId: doc._id }); - if (activity) { - Activities.remove(activity._id); + const activities = Activities.find({ checklistId: doc._id }); + if (activities) { + activities.forEach((activity) => { + Activities.remove(activity._id); + }); } }); } |