diff options
author | Ghassen Rjab <rjab.ghassen@gmail.com> | 2017-07-26 22:51:15 +0100 |
---|---|---|
committer | Ghassen Rjab <rjab.ghassen@gmail.com> | 2017-07-26 22:51:15 +0100 |
commit | 2b9bc5d04652a7e8c9ec65b8bc81f93e27d196a1 (patch) | |
tree | aa608c1620372f2419886d94232a8ea6ae11d3b5 /models | |
parent | 01928bfe5af504d6e921b59e4070339d86097a28 (diff) | |
download | wekan-2b9bc5d04652a7e8c9ec65b8bc81f93e27d196a1.tar.gz wekan-2b9bc5d04652a7e8c9ec65b8bc81f93e27d196a1.tar.bz2 wekan-2b9bc5d04652a7e8c9ec65b8bc81f93e27d196a1.zip |
Add checklist items to activity log
Diffstat (limited to 'models')
-rw-r--r-- | models/activities.js | 3 | ||||
-rw-r--r-- | models/checklists.js | 23 |
2 files changed, 16 insertions, 10 deletions
diff --git a/models/activities.js b/models/activities.js index f1e52493..b7fbc61b 100644 --- a/models/activities.js +++ b/models/activities.js @@ -38,6 +38,9 @@ Activities.helpers({ checklist() { return Checklists.findOne(this.checklistId); }, + checklistItem() { + return Checklists.findOne(this.checklistId).getItem(this.checklistItemId); + }, }); Activities.before.insert((userId, doc) => { diff --git a/models/checklists.js b/models/checklists.js index 0ee62fa2..ab4fe61d 100644 --- a/models/checklists.js +++ b/models/checklists.js @@ -161,16 +161,19 @@ if (Meteor.isServer) { }); //TODO: so there will be no activity for adding item into checklist, maybe will be implemented in the future. - // Checklists.after.update((userId, doc) => { - // console.log('update:', doc) - // Activities.insert({ - // userId, - // activityType: 'addChecklist', - // boardId: doc.boardId, - // cardId: doc.cardId, - // checklistId: doc._id, - // }); - // }); + // 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, + }); + } + }); Checklists.before.remove((userId, doc) => { const activity = Activities.findOne({ checklistId: doc._id }); |