boardsList.js 1.1 KB

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