- 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

@ -23,10 +23,11 @@ template(name='homeSidebar')
hr
+labelsWidget
hr
h3
i.fa.fa-comments-o
| {{_ 'activities'}}
+activities(mode="board")
unless currentUser.isNoComments
h3
i.fa.fa-comments-o
| {{_ 'activities'}}
+activities(mode="board")
template(name="membersWidget")
.board-widget.board-widget-members
@ -145,6 +146,12 @@ template(name="changePermissionsPopup")
if isNormal
i.fa.fa-check
span.sub-name {{_ 'normal-desc'}}
li
a(class="{{#if isLastAdmin}}disabled{{else}}js-set-no-comments{{/if}}")
| {{_ 'no-comments'}}
if isNoComments
i.fa.fa-check
span.sub-name {{_ 'no-comments-desc'}}
li
a(class="{{#if isLastAdmin}}disabled{{else}}js-set-comment-only{{/if}}")
| {{_ 'comment-only'}}

View file

@ -126,8 +126,11 @@ Template.memberPopup.helpers({
if(type === 'normal'){
const currentBoard = Boards.findOne(Session.get('currentBoard'));
const commentOnly = currentBoard.hasCommentOnly(this.userId);
const noComments = currentBoard.hasNoComments(this.userId);
if(commentOnly){
return TAPi18n.__('comment-only').toLowerCase();
} else if(noComments) {
return TAPi18n.__('no-comments').toLowerCase();
} else {
return TAPi18n.__(type).toLowerCase();
}
@ -324,12 +327,13 @@ BlazeComponent.extendComponent({
}).register('addMemberPopup');
Template.changePermissionsPopup.events({
'click .js-set-admin, click .js-set-normal, click .js-set-comment-only'(event) {
'click .js-set-admin, click .js-set-normal, click .js-set-no-comments, click .js-set-comment-only'(event) {
const currentBoard = Boards.findOne(Session.get('currentBoard'));
const memberId = this.userId;
const isAdmin = $(event.currentTarget).hasClass('js-set-admin');
const isCommentOnly = $(event.currentTarget).hasClass('js-set-comment-only');
currentBoard.setMemberPermission(memberId, isAdmin, isCommentOnly);
const isNoComments = $(event.currentTarget).hasClass('js-set-no-comments');
currentBoard.setMemberPermission(memberId, isAdmin, isNoComments, isCommentOnly);
Popup.back(1);
},
});
@ -342,7 +346,12 @@ Template.changePermissionsPopup.helpers({
isNormal() {
const currentBoard = Boards.findOne(Session.get('currentBoard'));
return !currentBoard.hasAdmin(this.userId) && !currentBoard.hasCommentOnly(this.userId);
return !currentBoard.hasAdmin(this.userId) && !currentBoard.hasNoComments(this.userId) && !currentBoard.hasCommentOnly(this.userId);
},
isNoComments() {
const currentBoard = Boards.findOne(Session.get('currentBoard'));
return !currentBoard.hasAdmin(this.userId) && currentBoard.hasNoComments(this.userId);
},
isCommentOnly() {