diff options
Diffstat (limited to 'models/swimlanes.js')
-rw-r--r-- | models/swimlanes.js | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/models/swimlanes.js b/models/swimlanes.js index 9da4afb5..bd2565af 100644 --- a/models/swimlanes.js +++ b/models/swimlanes.js @@ -180,6 +180,10 @@ Swimlanes.helpers({ const user = Users.findOne(Meteor.userId()); return user.profile.boardTemplatesSwimlaneId === this._id; }, + + remove() { + Swimlanes.remove({ _id: this._id}); + }, }); Swimlanes.mutations({ @@ -234,7 +238,21 @@ if (Meteor.isServer) { }); }); - Swimlanes.before.remove((userId, doc) => { + Swimlanes.before.remove(function(userId, doc) { + const lists = Lists.find({ + boardId: doc.boardId, + swimlaneId: {$in: [doc._id, '']}, + archived: false, + }, { sort: ['sort'] }); + + if (lists.count() < 2) { + lists.forEach((list) => { + list.remove(); + }); + } else { + Cards.remove({swimlaneId: doc._id}); + } + Activities.insert({ userId, type: 'swimlane', |