diff options
author | Lauri Ojansivu <x@xet7.org> | 2018-09-04 20:09:36 +0300 |
---|---|---|
committer | Lauri Ojansivu <x@xet7.org> | 2018-09-04 20:09:36 +0300 |
commit | 77efcf71376d3da6c19ad1a4910567263e83c0ca (patch) | |
tree | cf771daed5671379fa616fbb6aed42baab8834d5 /models | |
parent | bcbe1aaaf561f3188111b586ad0734b983206482 (diff) | |
download | wekan-77efcf71376d3da6c19ad1a4910567263e83c0ca.tar.gz wekan-77efcf71376d3da6c19ad1a4910567263e83c0ca.tar.bz2 wekan-77efcf71376d3da6c19ad1a4910567263e83c0ca.zip |
- Add permission "No comments". It is like normal user, but does not show comments and activities.
Thanks to xet7 !
Diffstat (limited to 'models')
-rw-r--r-- | models/boards.js | 13 | ||||
-rw-r--r-- | models/lists.js | 6 | ||||
-rw-r--r-- | models/swimlanes.js | 6 | ||||
-rw-r--r-- | models/users.js | 10 |
4 files changed, 28 insertions, 7 deletions
diff --git a/models/boards.js b/models/boards.js index a017eb3f..71049bd9 100644 --- a/models/boards.js +++ b/models/boards.js @@ -110,6 +110,7 @@ Boards.attachSchema(new SimpleSchema({ userId: this.userId, isAdmin: true, isActive: true, + isNoComments: false, isCommentOnly: false, }]; } @@ -124,6 +125,9 @@ Boards.attachSchema(new SimpleSchema({ 'members.$.isActive': { type: Boolean, }, + 'members.$.isNoComments': { + type: Boolean, + }, 'members.$.isCommentOnly': { type: Boolean, }, @@ -292,6 +296,10 @@ Boards.helpers({ return !!_.findWhere(this.members, { userId: memberId, isActive: true, isAdmin: true }); }, + hasNoComments(memberId) { + return !!_.findWhere(this.members, { userId: memberId, isActive: true, isAdmin: false, isNoComments: true }); + }, + hasCommentOnly(memberId) { return !!_.findWhere(this.members, { userId: memberId, isActive: true, isAdmin: false, isCommentOnly: true }); }, @@ -501,6 +509,7 @@ Boards.mutations({ userId: memberId, isAdmin: false, isActive: true, + isNoComments: false, isCommentOnly: false, }, }, @@ -528,7 +537,7 @@ Boards.mutations({ }; }, - setMemberPermission(memberId, isAdmin, isCommentOnly) { + setMemberPermission(memberId, isAdmin, isNoComments, isCommentOnly) { const memberIndex = this.memberIndex(memberId); // do not allow change permission of self @@ -539,6 +548,7 @@ Boards.mutations({ return { $set: { [`members.${memberIndex}.isAdmin`]: isAdmin, + [`members.${memberIndex}.isNoComments`]: isNoComments, [`members.${memberIndex}.isCommentOnly`]: isCommentOnly, }, }; @@ -838,6 +848,7 @@ if (Meteor.isServer) { userId: req.body.owner, isAdmin: true, isActive: true, + isNoComments: false, isCommentOnly: false, }, ], diff --git a/models/lists.js b/models/lists.js index 6f6996cb..9bcb9ba1 100644 --- a/models/lists.js +++ b/models/lists.js @@ -63,13 +63,13 @@ Lists.attachSchema(new SimpleSchema({ Lists.allow({ insert(userId, doc) { - return allowIsBoardMemberNonComment(userId, Boards.findOne(doc.boardId)); + return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId)); }, update(userId, doc) { - return allowIsBoardMemberNonComment(userId, Boards.findOne(doc.boardId)); + return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId)); }, remove(userId, doc) { - return allowIsBoardMemberNonComment(userId, Boards.findOne(doc.boardId)); + return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId)); }, fetch: ['boardId'], }); diff --git a/models/swimlanes.js b/models/swimlanes.js index 72ef3f36..3559bcd2 100644 --- a/models/swimlanes.js +++ b/models/swimlanes.js @@ -46,13 +46,13 @@ Swimlanes.attachSchema(new SimpleSchema({ Swimlanes.allow({ insert(userId, doc) { - return allowIsBoardMemberNonComment(userId, Boards.findOne(doc.boardId)); + return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId)); }, update(userId, doc) { - return allowIsBoardMemberNonComment(userId, Boards.findOne(doc.boardId)); + return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId)); }, remove(userId, doc) { - return allowIsBoardMemberNonComment(userId, Boards.findOne(doc.boardId)); + return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId)); }, fetch: ['boardId'], }); diff --git a/models/users.js b/models/users.js index 1b1b79e1..01673e4f 100644 --- a/models/users.js +++ b/models/users.js @@ -151,6 +151,16 @@ if (Meteor.isClient) { return board && board.hasMember(this._id); }, + isNotNoComments() { + const board = Boards.findOne(Session.get('currentBoard')); + return board && board.hasMember(this._id) && !board.hasNoComments(this._id); + }, + + isNoComments() { + const board = Boards.findOne(Session.get('currentBoard')); + return board && board.hasNoComments(this._id); + }, + isNotCommentOnly() { const board = Boards.findOne(Session.get('currentBoard')); return board && board.hasMember(this._id) && !board.hasCommentOnly(this._id); |