mirror of
https://github.com/wekan/wekan.git
synced 2025-04-23 13:37:09 -04:00
- Add permission "No comments". It is like normal user, but does not show comments and activities.
Thanks to xet7 !
This commit is contained in:
parent
bcbe1aaaf5
commit
77efcf7137
12 changed files with 88 additions and 39 deletions
|
@ -121,7 +121,8 @@
|
|||
"allowIsBoardAdmin": true,
|
||||
"allowIsBoardMember": true,
|
||||
"allowIsBoardMemberByCard": true,
|
||||
"allowIsBoardMemberNonComment": true,
|
||||
"allowIsBoardMemberCommentOnly": true,
|
||||
"allowIsBoardMemberNoComments": true,
|
||||
"Emoji": true,
|
||||
"Checklists": true,
|
||||
"Settings": true,
|
||||
|
|
|
@ -173,25 +173,28 @@ template(name="cardDetails")
|
|||
+attachmentsGalery
|
||||
|
||||
hr
|
||||
.activity-title
|
||||
h3 {{ _ 'activity'}}
|
||||
if currentUser.isBoardMember
|
||||
.material-toggle-switch
|
||||
span.toggle-switch-title {{_ 'hide-system-messages'}}
|
||||
if hiddenSystemMessages
|
||||
input.toggle-switch(type="checkbox" id="toggleButton" checked="checked")
|
||||
else
|
||||
input.toggle-switch(type="checkbox" id="toggleButton")
|
||||
label.toggle-label(for="toggleButton")
|
||||
unless currentUser.isNoComments
|
||||
.activity-title
|
||||
h3 {{ _ 'activity'}}
|
||||
if currentUser.isBoardMember
|
||||
.material-toggle-switch
|
||||
span.toggle-switch-title {{_ 'hide-system-messages'}}
|
||||
if hiddenSystemMessages
|
||||
input.toggle-switch(type="checkbox" id="toggleButton" checked="checked")
|
||||
else
|
||||
input.toggle-switch(type="checkbox" id="toggleButton")
|
||||
label.toggle-label(for="toggleButton")
|
||||
if currentUser.isBoardMember
|
||||
+commentForm
|
||||
if isLoaded.get
|
||||
if isLinkedCard
|
||||
+activities(card=this mode="linkedcard")
|
||||
else if isLinkedBoard
|
||||
+activities(card=this mode="linkedboard")
|
||||
else
|
||||
+activities(card=this mode="card")
|
||||
unless currentUser.isNoComments
|
||||
+commentForm
|
||||
unless currentUser.isNoComments
|
||||
if isLoaded.get
|
||||
if isLinkedCard
|
||||
+activities(card=this mode="linkedcard")
|
||||
else if isLinkedBoard
|
||||
+activities(card=this mode="linkedboard")
|
||||
else
|
||||
+activities(card=this mode="card")
|
||||
|
||||
template(name="editCardTitleForm")
|
||||
textarea.js-edit-card-title(rows='1' autofocus)
|
||||
|
|
|
@ -65,10 +65,11 @@ template(name="minicard")
|
|||
+userAvatar(userId=this)
|
||||
|
||||
.badges
|
||||
if comments.count
|
||||
.badge(title="{{_ 'card-comments-title' comments.count }}")
|
||||
span.badge-icon.fa.fa-comment-o.badge-comment
|
||||
span.badge-text= comments.count
|
||||
unless currentUser.isNoComments
|
||||
if comments.count
|
||||
.badge(title="{{_ 'card-comments-title' comments.count }}")
|
||||
span.badge-icon.fa.fa-comment-o.badge-comment
|
||||
span.badge-text= comments.count
|
||||
if getDescription
|
||||
.badge.badge-state-image-only(title=getDescription)
|
||||
span.badge-icon.fa.fa-align-left
|
||||
|
|
|
@ -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'}}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -171,6 +171,8 @@
|
|||
"comment-placeholder": "Write Comment",
|
||||
"comment-only": "Comment only",
|
||||
"comment-only-desc": "Can comment on cards only.",
|
||||
"no-comments": "No comments",
|
||||
"no-comments-desc": "Can not see comments and activities.",
|
||||
"computer": "Computer",
|
||||
"confirm-subtask-delete-dialog": "Are you sure you want to delete subtask?",
|
||||
"confirm-checklist-delete-dialog": "Are you sure you want to delete checklist?",
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
],
|
||||
|
|
|
@ -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'],
|
||||
});
|
||||
|
|
|
@ -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'],
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -208,7 +208,8 @@ if (isSandstorm && Meteor.isServer) {
|
|||
const isActive = permissions.indexOf('participate') > -1;
|
||||
const isAdmin = permissions.indexOf('configure') > -1;
|
||||
const isCommentOnly = false;
|
||||
const permissionDoc = { userId, isActive, isAdmin, isCommentOnly };
|
||||
const isNoComments = false;
|
||||
const permissionDoc = { userId, isActive, isAdmin, isNoComments, isCommentOnly };
|
||||
|
||||
const boardMembers = Boards.findOne(sandstormBoard._id).members;
|
||||
const memberIndex = _.pluck(boardMembers, 'userId').indexOf(userId);
|
||||
|
|
|
@ -6,10 +6,14 @@ allowIsBoardMember = function(userId, board) {
|
|||
return board && board.hasMember(userId);
|
||||
};
|
||||
|
||||
allowIsBoardMemberNonComment = function(userId, board) {
|
||||
allowIsBoardMemberCommentOnly = function(userId, board) {
|
||||
return board && board.hasMember(userId) && !board.hasCommentOnly(userId);
|
||||
};
|
||||
|
||||
allowIsBoardMemberNoComments = function(userId, board) {
|
||||
return board && board.hasMember(userId) && !board.hasNoComments(userId);
|
||||
};
|
||||
|
||||
allowIsBoardMemberByCard = function(userId, card) {
|
||||
const board = card.board();
|
||||
return board && board.hasMember(userId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue