Browse Source

Unassign members before removing them from a board

Closes #399
Maxime Quandalle 9 years ago
parent
commit
8a47cfa4ba
1 changed files with 5 additions and 2 deletions
  1. 5 2
      client/components/sidebar/sidebar.js

+ 5 - 2
client/components/sidebar/sidebar.js

@@ -131,9 +131,12 @@ Template.memberPopup.events({
   },
   'click .js-change-role': Popup.open('changePermissions'),
   'click .js-remove-member': Popup.afterConfirm('removeMember', function() {
-    const currentBoard = Boards.findOne(Session.get('currentBoard'));
+    const boardId = Session.get('currentBoard');
     const memberId = this.userId;
-    currentBoard.removeMember(memberId);
+    Cards.find({ boardId, members: memberId }).forEach((card) => {
+      card.unassignMember(memberId);
+    });
+    Boards.findOne(boardId).removeMember(memberId);
     Popup.close();
   }),
   'click .js-leave-member'() {