boardsList.js 1.5 KB

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