boardsList.js 1.8 KB

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