remove feature

This commit is contained in:
guillaume 2019-04-23 18:00:09 +02:00
parent 6933424fca
commit 8137f2692f
10 changed files with 135 additions and 14 deletions

View file

@ -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')) {