boardsList.js 1.9 KB

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