From ee938c04232ab9ac42195a35d38cb7ae11b14d48 Mon Sep 17 00:00:00 2001 From: Ghassen Rjab Date: Thu, 31 Aug 2017 06:58:02 +0100 Subject: [PATCH 1/3] Delete activity related to checklist item when the item is deleted --- models/checklists.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/models/checklists.js b/models/checklists.js index ab4fe61d8..596827206 100644 --- a/models/checklists.js +++ b/models/checklists.js @@ -164,14 +164,23 @@ 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); + } + } } }); From a579125a1faa2ecbf3b7be535ac2ee1a2d3c5bca Mon Sep 17 00:00:00 2001 From: Ghassen Rjab Date: Thu, 31 Aug 2017 06:58:32 +0100 Subject: [PATCH 2/3] Delete all activities related to a checklist when it is deleted --- models/checklists.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/models/checklists.js b/models/checklists.js index 596827206..2521412f0 100644 --- a/models/checklists.js +++ b/models/checklists.js @@ -185,9 +185,11 @@ if (Meteor.isServer) { }); 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); + }); } }); } From 8d37a0418aaf2987c2d2bb22f2062ed7cbe9aaef Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Fri, 1 Sep 2017 22:04:56 +0300 Subject: [PATCH 3/3] Fix errors caused by checklist items activities. Thanks to GhassenRjab and nztqa ! Closes #1198 --- CHANGELOG.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c2896a44..b63c0a131 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: