diff options
Diffstat (limited to 'collections')
-rw-r--r-- | collections/boards.js | 8 | ||||
-rw-r--r-- | collections/users.js | 8 |
2 files changed, 14 insertions, 2 deletions
diff --git a/collections/boards.js b/collections/boards.js index 8260fc3d..ddfa5016 100644 --- a/collections/boards.js +++ b/collections/boards.js @@ -123,16 +123,24 @@ Boards.helpers({ isPublic() { return this.permission === 'public'; }, + lists() { return Lists.find({ boardId: this._id, archived: false }, { sort: { sort: 1 }}); }, + activities() { return Activities.find({ boardId: this._id }, { sort: { createdAt: -1 }}); }, + + activeMembers() { + return _.where(this.members, {isActive: true}); + }, + absoluteUrl() { return FlowRouter.path('board', { id: this._id, slug: this.slug }); }, + colorClass() { return `board-color-${this.color}`; }, diff --git a/collections/users.js b/collections/users.js index 276c9f9e..34a94605 100644 --- a/collections/users.js +++ b/collections/users.js @@ -12,23 +12,27 @@ Users.helpers({ boards() { return Boards.find({ userId: this._id }); }, + starredBoards() { const starredBoardIds = this.profile.starredBoards || []; return Boards.find({archived: false, _id: {$in: starredBoardIds}}); }, + hasStarred(boardId) { const starredBoardIds = this.profile.starredBoards || []; return _.contains(starredBoardIds, boardId); }, + isBoardMember() { const board = Boards.findOne(Session.get('currentBoard')); return board && _.contains(_.pluck(board.members, 'userId'), this._id) && _.where(board.members, {userId: this._id})[0].isActive; }, + isBoardAdmin() { const board = Boards.findOne(Session.get('currentBoard')); - if (this.isBoardMember(board)) - return _.where(board.members, {userId: this._id})[0].isAdmin; + return board && this.isBoardMember(board) && + _.where(board.members, {userId: this._id})[0].isAdmin; }, getInitials() { |