diff options
Diffstat (limited to 'models/boards.js')
-rw-r--r-- | models/boards.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/models/boards.js b/models/boards.js index 36651d54..b07d9e27 100644 --- a/models/boards.js +++ b/models/boards.js @@ -803,6 +803,13 @@ Boards.mutations({ }, }); +function boardRemover(userId, doc) { + [Cards, Lists, Swimlanes, Integrations, Rules, Activities].forEach((element) => { + element.remove({ boardId: doc._id }); + }); +} + + if (Meteor.isServer) { Boards.allow({ insert: Meteor.userId, @@ -966,6 +973,18 @@ if (Meteor.isServer) { } }); + Boards.before.remove((userId, doc) => { + boardRemover(userId, doc); + // Add removeBoard activity to keep it + Activities.insert({ + userId, + type: 'board', + activityTypeId: doc._id, + activityType: 'removeBoard', + boardId: doc._id, + }); + }); + // Add a new activity if we add or remove a member to the board Boards.after.update((userId, doc, fieldNames, modifier) => { if (!_.contains(fieldNames, 'members')) { |