boardList.js 766 B

1234567891011121314151617181920212223242526272829303132333435
  1. BlazeComponent.extendComponent({
  2. template: function() {
  3. return 'boardList';
  4. },
  5. boards: function() {
  6. return Boards.find({}, {
  7. sort: ['title']
  8. });
  9. },
  10. starredBoards: function() {
  11. var cursor = Boards.find({
  12. _id: { $in: Meteor.user().profile.starredBoards || [] }
  13. }, {
  14. sort: ['title']
  15. });
  16. return cursor.count() === 0 ? null : cursor;
  17. },
  18. isStarred: function() {
  19. var user = Meteor.user();
  20. return user && user.hasStarred(this._id);
  21. },
  22. events: function() {
  23. return [{
  24. 'click .js-add-board': Popup.open('createBoard'),
  25. 'click .js-star-board': function(evt) {
  26. Meteor.user().toggleBoardStar(this._id);
  27. evt.preventDefault();
  28. },
  29. }];
  30. }
  31. }).register('boardList');