2
0

boardsList.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. BlazeComponent.extendComponent({
  2. boards() {
  3. return Boards.find({
  4. archived: false,
  5. 'members.userId': Meteor.userId(),
  6. }, {
  7. sort: ['title'],
  8. });
  9. },
  10. isStarred() {
  11. const user = Meteor.user();
  12. return user && user.hasStarred(this.currentData()._id);
  13. },
  14. isInvited() {
  15. const user = Meteor.user();
  16. return user && user.isInvitedTo(this.currentData()._id);
  17. },
  18. events() {
  19. return [{
  20. 'click .js-add-board': Popup.open('createBoard'),
  21. 'click .js-star-board'(evt) {
  22. const boardId = this.currentData()._id;
  23. Meteor.user().toggleBoardStar(boardId);
  24. evt.preventDefault();
  25. },
  26. 'click .js-accept-invite'() {
  27. const boardId = this.currentData()._id;
  28. Meteor.user().removeInvite(boardId);
  29. },
  30. 'click .js-decline-invite'() {
  31. const boardId = this.currentData()._id;
  32. Meteor.call('quitBoard', boardId, (err, ret) => {
  33. if (!err && ret) {
  34. Meteor.user().removeInvite(boardId);
  35. FlowRouter.go('home');
  36. }
  37. });
  38. },
  39. }];
  40. },
  41. }).register('boardList');