boardsList.js 1.4 KB

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