boardsList.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. }, { sort: [['stars', 'desc'], ['color', 'asc'], ['title', 'asc'], ['description', 'asc'], ['_id', 'asc']] });
  26. },
  27. isStarred() {
  28. const user = Meteor.user();
  29. return user && user.hasStarred(this.currentData()._id);
  30. },
  31. hasOvertimeCards() {
  32. subManager.subscribe('board', this.currentData()._id);
  33. return this.currentData().hasOvertimeCards();
  34. },
  35. hasSpentTimeCards() {
  36. subManager.subscribe('board', this.currentData()._id);
  37. return this.currentData().hasSpentTimeCards();
  38. },
  39. isInvited() {
  40. const user = Meteor.user();
  41. return user && user.isInvitedTo(this.currentData()._id);
  42. },
  43. events() {
  44. return [{
  45. 'click .js-add-board': Popup.open('createBoard'),
  46. 'click .js-star-board'(evt) {
  47. const boardId = this.currentData()._id;
  48. Meteor.user().toggleBoardStar(boardId);
  49. evt.preventDefault();
  50. },
  51. 'click .js-accept-invite'() {
  52. const boardId = this.currentData()._id;
  53. Meteor.user().removeInvite(boardId);
  54. },
  55. 'click .js-decline-invite'() {
  56. const boardId = this.currentData()._id;
  57. Meteor.call('quitBoard', boardId, (err, ret) => {
  58. if (!err && ret) {
  59. Meteor.user().removeInvite(boardId);
  60. FlowRouter.go('home');
  61. }
  62. });
  63. },
  64. }];
  65. },
  66. }).register('boardList');