diff options
author | guillaume <guillaume.cassou@orange.fr> | 2019-04-23 18:00:09 +0200 |
---|---|---|
committer | guillaume <guillaume.cassou@orange.fr> | 2019-04-23 18:00:09 +0200 |
commit | 8137f2692fe3e1d9f1c0a9b635ef15cdf36728f7 (patch) | |
tree | a054ec502113381363254b8d386de05bfd1626e4 /models/boards.js | |
parent | 6933424fca56fc84b0060ff97b97303d36ab5fb0 (diff) | |
download | wekan-8137f2692fe3e1d9f1c0a9b635ef15cdf36728f7.tar.gz wekan-8137f2692fe3e1d9f1c0a9b635ef15cdf36728f7.tar.bz2 wekan-8137f2692fe3e1d9f1c0a9b635ef15cdf36728f7.zip |
remove feature
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')) { |