summaryrefslogtreecommitdiffstats
path: root/client/components/boards/helpers.js
blob: 05be987dc8fe0e8e87b0c91e4999f3403de58f4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Template.boards.helpers({
  boards: function() {
    return Boards.find({}, {
      sort: ['title']
    });
  },

  starredBoards: function() {
    var cursor = Boards.find({
      _id: { $in: Meteor.user().profile.starredBoards || [] }
    }, {
      sort: ['title']
    });
    return cursor.count() === 0 ? null : cursor;
  },

  isStarred: function() {
    var user = Meteor.user();
    return user && user.hasStarred(this._id);
  }
});

Template.boardChangePermissionPopup.helpers({
  check: function(perm) {
    return this.permission === perm;
  }
});

Template.boardChangeColorPopup.helpers({
  backgroundColors: function() {
    return Boards.simpleSchema()._schema.color.allowedValues;
  },

  isSelected: function() {
    var currentBoard = Boards.findOne(Session.get('currentBoard'));
    return currentBoard.color === this.toString();
  }
});

Blaze.registerHelper('currentBoard', function() {
  var boardId = Session.get('currentBoard');
  if (boardId) {
    return Boards.findOne(boardId);
  }
});