summaryrefslogtreecommitdiffstats
path: root/client/components/boards/boardList.js
blob: f902cc843a4577eee124cc6cb51a6a2806f83d31 (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
BlazeComponent.extendComponent({
  template: function() {
    return 'boardList';
  },

  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);
  },

  events: function() {
    return [{
      'click .js-add-board': Popup.open('createBoard'),
      'click .js-star-board': function(evt) {
        Meteor.user().toggleBoardStar(this._id);
        evt.preventDefault();
      }
    }];
  }
}).register('boardList');