helpers.js 1013 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. Template.boards.helpers({
  2. boards: function() {
  3. return Boards.find({}, {
  4. sort: ['title']
  5. });
  6. },
  7. starredBoards: function() {
  8. var cursor = Boards.find({
  9. _id: { $in: Meteor.user().profile.starredBoards || [] }
  10. }, {
  11. sort: ['title']
  12. });
  13. return cursor.count() === 0 ? null : cursor;
  14. },
  15. isStarred: function() {
  16. var user = Meteor.user();
  17. return user && user.hasStarred(this._id);
  18. }
  19. });
  20. Template.boardChangePermissionPopup.helpers({
  21. check: function(perm) {
  22. return this.permission === perm;
  23. }
  24. });
  25. Template.boardChangeColorPopup.helpers({
  26. backgroundColors: function() {
  27. return Boards.simpleSchema()._schema.color.allowedValues;
  28. },
  29. isSelected: function() {
  30. var currentBoard = Boards.findOne(Session.get('currentBoard'));
  31. return currentBoard.color === this.toString();
  32. }
  33. });
  34. Blaze.registerHelper('currentBoard', function() {
  35. var boardId = Session.get('currentBoard');
  36. if (boardId) {
  37. return Boards.findOne(boardId);
  38. }
  39. });