- Add permission "No comments". It is like normal user, but does not show comments and activities.

Thanks to xet7 !
This commit is contained in:
Lauri Ojansivu 2018-09-04 20:09:36 +03:00
parent bcbe1aaaf5
commit 77efcf7137
12 changed files with 88 additions and 39 deletions

View file

@ -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,
},
],