boardList.js 709 B

12345678910111213141516171819202122232425262728293031323334
  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-star-board': function(evt) {
  25. Meteor.user().toggleBoardStar(this._id);
  26. evt.preventDefault();
  27. }
  28. }];
  29. }
  30. }).register('boardList');