mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 15:30:13 +01: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,
|
"allowIsBoardAdmin": true,
|
||||||
"allowIsBoardMember": true,
|
"allowIsBoardMember": true,
|
||||||
"allowIsBoardMemberByCard": true,
|
"allowIsBoardMemberByCard": true,
|
||||||
"allowIsBoardMemberNonComment": true,
|
"allowIsBoardMemberCommentOnly": true,
|
||||||
|
"allowIsBoardMemberNoComments": true,
|
||||||
"Emoji": true,
|
"Emoji": true,
|
||||||
"Checklists": true,
|
"Checklists": true,
|
||||||
"Settings": true,
|
"Settings": true,
|
||||||
|
|
|
||||||
|
|
@ -173,25 +173,28 @@ template(name="cardDetails")
|
||||||
+attachmentsGalery
|
+attachmentsGalery
|
||||||
|
|
||||||
hr
|
hr
|
||||||
.activity-title
|
unless currentUser.isNoComments
|
||||||
h3 {{ _ 'activity'}}
|
.activity-title
|
||||||
if currentUser.isBoardMember
|
h3 {{ _ 'activity'}}
|
||||||
.material-toggle-switch
|
if currentUser.isBoardMember
|
||||||
span.toggle-switch-title {{_ 'hide-system-messages'}}
|
.material-toggle-switch
|
||||||
if hiddenSystemMessages
|
span.toggle-switch-title {{_ 'hide-system-messages'}}
|
||||||
input.toggle-switch(type="checkbox" id="toggleButton" checked="checked")
|
if hiddenSystemMessages
|
||||||
else
|
input.toggle-switch(type="checkbox" id="toggleButton" checked="checked")
|
||||||
input.toggle-switch(type="checkbox" id="toggleButton")
|
else
|
||||||
label.toggle-label(for="toggleButton")
|
input.toggle-switch(type="checkbox" id="toggleButton")
|
||||||
|
label.toggle-label(for="toggleButton")
|
||||||
if currentUser.isBoardMember
|
if currentUser.isBoardMember
|
||||||
+commentForm
|
unless currentUser.isNoComments
|
||||||
if isLoaded.get
|
+commentForm
|
||||||
if isLinkedCard
|
unless currentUser.isNoComments
|
||||||
+activities(card=this mode="linkedcard")
|
if isLoaded.get
|
||||||
else if isLinkedBoard
|
if isLinkedCard
|
||||||
+activities(card=this mode="linkedboard")
|
+activities(card=this mode="linkedcard")
|
||||||
else
|
else if isLinkedBoard
|
||||||
+activities(card=this mode="card")
|
+activities(card=this mode="linkedboard")
|
||||||
|
else
|
||||||
|
+activities(card=this mode="card")
|
||||||
|
|
||||||
template(name="editCardTitleForm")
|
template(name="editCardTitleForm")
|
||||||
textarea.js-edit-card-title(rows='1' autofocus)
|
textarea.js-edit-card-title(rows='1' autofocus)
|
||||||
|
|
|
||||||
|
|
@ -65,10 +65,11 @@ template(name="minicard")
|
||||||
+userAvatar(userId=this)
|
+userAvatar(userId=this)
|
||||||
|
|
||||||
.badges
|
.badges
|
||||||
if comments.count
|
unless currentUser.isNoComments
|
||||||
.badge(title="{{_ 'card-comments-title' comments.count }}")
|
if comments.count
|
||||||
span.badge-icon.fa.fa-comment-o.badge-comment
|
.badge(title="{{_ 'card-comments-title' comments.count }}")
|
||||||
span.badge-text= comments.count
|
span.badge-icon.fa.fa-comment-o.badge-comment
|
||||||
|
span.badge-text= comments.count
|
||||||
if getDescription
|
if getDescription
|
||||||
.badge.badge-state-image-only(title=getDescription)
|
.badge.badge-state-image-only(title=getDescription)
|
||||||
span.badge-icon.fa.fa-align-left
|
span.badge-icon.fa.fa-align-left
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,11 @@ template(name='homeSidebar')
|
||||||
hr
|
hr
|
||||||
+labelsWidget
|
+labelsWidget
|
||||||
hr
|
hr
|
||||||
h3
|
unless currentUser.isNoComments
|
||||||
i.fa.fa-comments-o
|
h3
|
||||||
| {{_ 'activities'}}
|
i.fa.fa-comments-o
|
||||||
+activities(mode="board")
|
| {{_ 'activities'}}
|
||||||
|
+activities(mode="board")
|
||||||
|
|
||||||
template(name="membersWidget")
|
template(name="membersWidget")
|
||||||
.board-widget.board-widget-members
|
.board-widget.board-widget-members
|
||||||
|
|
@ -145,6 +146,12 @@ template(name="changePermissionsPopup")
|
||||||
if isNormal
|
if isNormal
|
||||||
i.fa.fa-check
|
i.fa.fa-check
|
||||||
span.sub-name {{_ 'normal-desc'}}
|
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
|
li
|
||||||
a(class="{{#if isLastAdmin}}disabled{{else}}js-set-comment-only{{/if}}")
|
a(class="{{#if isLastAdmin}}disabled{{else}}js-set-comment-only{{/if}}")
|
||||||
| {{_ 'comment-only'}}
|
| {{_ 'comment-only'}}
|
||||||
|
|
|
||||||
|
|
@ -126,8 +126,11 @@ Template.memberPopup.helpers({
|
||||||
if(type === 'normal'){
|
if(type === 'normal'){
|
||||||
const currentBoard = Boards.findOne(Session.get('currentBoard'));
|
const currentBoard = Boards.findOne(Session.get('currentBoard'));
|
||||||
const commentOnly = currentBoard.hasCommentOnly(this.userId);
|
const commentOnly = currentBoard.hasCommentOnly(this.userId);
|
||||||
|
const noComments = currentBoard.hasNoComments(this.userId);
|
||||||
if(commentOnly){
|
if(commentOnly){
|
||||||
return TAPi18n.__('comment-only').toLowerCase();
|
return TAPi18n.__('comment-only').toLowerCase();
|
||||||
|
} else if(noComments) {
|
||||||
|
return TAPi18n.__('no-comments').toLowerCase();
|
||||||
} else {
|
} else {
|
||||||
return TAPi18n.__(type).toLowerCase();
|
return TAPi18n.__(type).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
@ -324,12 +327,13 @@ BlazeComponent.extendComponent({
|
||||||
}).register('addMemberPopup');
|
}).register('addMemberPopup');
|
||||||
|
|
||||||
Template.changePermissionsPopup.events({
|
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 currentBoard = Boards.findOne(Session.get('currentBoard'));
|
||||||
const memberId = this.userId;
|
const memberId = this.userId;
|
||||||
const isAdmin = $(event.currentTarget).hasClass('js-set-admin');
|
const isAdmin = $(event.currentTarget).hasClass('js-set-admin');
|
||||||
const isCommentOnly = $(event.currentTarget).hasClass('js-set-comment-only');
|
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);
|
Popup.back(1);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -342,7 +346,12 @@ Template.changePermissionsPopup.helpers({
|
||||||
|
|
||||||
isNormal() {
|
isNormal() {
|
||||||
const currentBoard = Boards.findOne(Session.get('currentBoard'));
|
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() {
|
isCommentOnly() {
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,8 @@
|
||||||
"comment-placeholder": "Write Comment",
|
"comment-placeholder": "Write Comment",
|
||||||
"comment-only": "Comment only",
|
"comment-only": "Comment only",
|
||||||
"comment-only-desc": "Can comment on cards only.",
|
"comment-only-desc": "Can comment on cards only.",
|
||||||
|
"no-comments": "No comments",
|
||||||
|
"no-comments-desc": "Can not see comments and activities.",
|
||||||
"computer": "Computer",
|
"computer": "Computer",
|
||||||
"confirm-subtask-delete-dialog": "Are you sure you want to delete subtask?",
|
"confirm-subtask-delete-dialog": "Are you sure you want to delete subtask?",
|
||||||
"confirm-checklist-delete-dialog": "Are you sure you want to delete checklist?",
|
"confirm-checklist-delete-dialog": "Are you sure you want to delete checklist?",
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,7 @@ Boards.attachSchema(new SimpleSchema({
|
||||||
userId: this.userId,
|
userId: this.userId,
|
||||||
isAdmin: true,
|
isAdmin: true,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
|
isNoComments: false,
|
||||||
isCommentOnly: false,
|
isCommentOnly: false,
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
@ -124,6 +125,9 @@ Boards.attachSchema(new SimpleSchema({
|
||||||
'members.$.isActive': {
|
'members.$.isActive': {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
},
|
},
|
||||||
|
'members.$.isNoComments': {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
'members.$.isCommentOnly': {
|
'members.$.isCommentOnly': {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
},
|
},
|
||||||
|
|
@ -292,6 +296,10 @@ Boards.helpers({
|
||||||
return !!_.findWhere(this.members, { userId: memberId, isActive: true, isAdmin: true });
|
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) {
|
hasCommentOnly(memberId) {
|
||||||
return !!_.findWhere(this.members, { userId: memberId, isActive: true, isAdmin: false, isCommentOnly: true });
|
return !!_.findWhere(this.members, { userId: memberId, isActive: true, isAdmin: false, isCommentOnly: true });
|
||||||
},
|
},
|
||||||
|
|
@ -501,6 +509,7 @@ Boards.mutations({
|
||||||
userId: memberId,
|
userId: memberId,
|
||||||
isAdmin: false,
|
isAdmin: false,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
|
isNoComments: false,
|
||||||
isCommentOnly: false,
|
isCommentOnly: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -528,7 +537,7 @@ Boards.mutations({
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
setMemberPermission(memberId, isAdmin, isCommentOnly) {
|
setMemberPermission(memberId, isAdmin, isNoComments, isCommentOnly) {
|
||||||
const memberIndex = this.memberIndex(memberId);
|
const memberIndex = this.memberIndex(memberId);
|
||||||
|
|
||||||
// do not allow change permission of self
|
// do not allow change permission of self
|
||||||
|
|
@ -539,6 +548,7 @@ Boards.mutations({
|
||||||
return {
|
return {
|
||||||
$set: {
|
$set: {
|
||||||
[`members.${memberIndex}.isAdmin`]: isAdmin,
|
[`members.${memberIndex}.isAdmin`]: isAdmin,
|
||||||
|
[`members.${memberIndex}.isNoComments`]: isNoComments,
|
||||||
[`members.${memberIndex}.isCommentOnly`]: isCommentOnly,
|
[`members.${memberIndex}.isCommentOnly`]: isCommentOnly,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
@ -838,6 +848,7 @@ if (Meteor.isServer) {
|
||||||
userId: req.body.owner,
|
userId: req.body.owner,
|
||||||
isAdmin: true,
|
isAdmin: true,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
|
isNoComments: false,
|
||||||
isCommentOnly: false,
|
isCommentOnly: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -63,13 +63,13 @@ Lists.attachSchema(new SimpleSchema({
|
||||||
|
|
||||||
Lists.allow({
|
Lists.allow({
|
||||||
insert(userId, doc) {
|
insert(userId, doc) {
|
||||||
return allowIsBoardMemberNonComment(userId, Boards.findOne(doc.boardId));
|
return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId));
|
||||||
},
|
},
|
||||||
update(userId, doc) {
|
update(userId, doc) {
|
||||||
return allowIsBoardMemberNonComment(userId, Boards.findOne(doc.boardId));
|
return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId));
|
||||||
},
|
},
|
||||||
remove(userId, doc) {
|
remove(userId, doc) {
|
||||||
return allowIsBoardMemberNonComment(userId, Boards.findOne(doc.boardId));
|
return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId));
|
||||||
},
|
},
|
||||||
fetch: ['boardId'],
|
fetch: ['boardId'],
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -46,13 +46,13 @@ Swimlanes.attachSchema(new SimpleSchema({
|
||||||
|
|
||||||
Swimlanes.allow({
|
Swimlanes.allow({
|
||||||
insert(userId, doc) {
|
insert(userId, doc) {
|
||||||
return allowIsBoardMemberNonComment(userId, Boards.findOne(doc.boardId));
|
return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId));
|
||||||
},
|
},
|
||||||
update(userId, doc) {
|
update(userId, doc) {
|
||||||
return allowIsBoardMemberNonComment(userId, Boards.findOne(doc.boardId));
|
return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId));
|
||||||
},
|
},
|
||||||
remove(userId, doc) {
|
remove(userId, doc) {
|
||||||
return allowIsBoardMemberNonComment(userId, Boards.findOne(doc.boardId));
|
return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId));
|
||||||
},
|
},
|
||||||
fetch: ['boardId'],
|
fetch: ['boardId'],
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,16 @@ if (Meteor.isClient) {
|
||||||
return board && board.hasMember(this._id);
|
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() {
|
isNotCommentOnly() {
|
||||||
const board = Boards.findOne(Session.get('currentBoard'));
|
const board = Boards.findOne(Session.get('currentBoard'));
|
||||||
return board && board.hasMember(this._id) && !board.hasCommentOnly(this._id);
|
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 isActive = permissions.indexOf('participate') > -1;
|
||||||
const isAdmin = permissions.indexOf('configure') > -1;
|
const isAdmin = permissions.indexOf('configure') > -1;
|
||||||
const isCommentOnly = false;
|
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 boardMembers = Boards.findOne(sandstormBoard._id).members;
|
||||||
const memberIndex = _.pluck(boardMembers, 'userId').indexOf(userId);
|
const memberIndex = _.pluck(boardMembers, 'userId').indexOf(userId);
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,14 @@ allowIsBoardMember = function(userId, board) {
|
||||||
return board && board.hasMember(userId);
|
return board && board.hasMember(userId);
|
||||||
};
|
};
|
||||||
|
|
||||||
allowIsBoardMemberNonComment = function(userId, board) {
|
allowIsBoardMemberCommentOnly = function(userId, board) {
|
||||||
return board && board.hasMember(userId) && !board.hasCommentOnly(userId);
|
return board && board.hasMember(userId) && !board.hasCommentOnly(userId);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
allowIsBoardMemberNoComments = function(userId, board) {
|
||||||
|
return board && board.hasMember(userId) && !board.hasNoComments(userId);
|
||||||
|
};
|
||||||
|
|
||||||
allowIsBoardMemberByCard = function(userId, card) {
|
allowIsBoardMemberByCard = function(userId, card) {
|
||||||
const board = card.board();
|
const board = card.board();
|
||||||
return board && board.hasMember(userId);
|
return board && board.hasMember(userId);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue