New Board Permissions: NormalAssignedOnly, CommentAssignedOnly, ReadOnly, ReadAssignedOnly.

Thanks to xet7 !

Fixes #1122,
fixes #6033,
fixes #3300
This commit is contained in:
Lauri Ojansivu 2025-12-22 21:45:09 +02:00
parent 21fb8e9164
commit c1168d181b
5 changed files with 190 additions and 4 deletions

View file

@ -225,6 +225,34 @@ Boards.attachSchema(
type: Boolean,
optional: true,
},
'members.$.isNormalAssignedOnly': {
/**
* Is the member only allowed to see assigned cards (Normal permission)
*/
type: Boolean,
optional: true,
},
'members.$.isCommentAssignedOnly': {
/**
* Is the member only allowed to comment on assigned cards
*/
type: Boolean,
optional: true,
},
'members.$.isReadOnly': {
/**
* Is the member only allowed to read the board (no comments, no editing)
*/
type: Boolean,
optional: true,
},
'members.$.isReadAssignedOnly': {
/**
* Is the member only allowed to read assigned cards (no comments, no editing)
*/
type: Boolean,
optional: true,
},
permission: {
/**
* visibility of the board
@ -979,6 +1007,44 @@ Boards.helpers({
});
},
hasNormalAssignedOnly(memberId) {
return !!_.findWhere(this.members, {
userId: memberId,
isActive: true,
isAdmin: false,
isNormalAssignedOnly: true,
isCommentAssignedOnly: false,
});
},
hasCommentAssignedOnly(memberId) {
return !!_.findWhere(this.members, {
userId: memberId,
isActive: true,
isAdmin: false,
isNormalAssignedOnly: false,
isCommentAssignedOnly: true,
});
},
hasReadOnly(memberId) {
return !!_.findWhere(this.members, {
userId: memberId,
isActive: true,
isAdmin: false,
isReadOnly: true,
});
},
hasReadAssignedOnly(memberId) {
return !!_.findWhere(this.members, {
userId: memberId,
isActive: true,
isAdmin: false,
isReadAssignedOnly: true,
});
},
hasAnyAllowsDate() {
const ret = this.allowsReceivedDate || this.allowsStartDate || this.allowsDueDate || this.allowsEndDate;
return ret;
@ -1416,6 +1482,10 @@ Boards.mutations({
isNoComments: false,
isCommentOnly: false,
isWorker: false,
isNormalAssignedOnly: false,
isCommentAssignedOnly: false,
isReadOnly: false,
isReadAssignedOnly: false,
},
},
};
@ -1449,6 +1519,10 @@ Boards.mutations({
isNoComments,
isCommentOnly,
isWorker,
isNormalAssignedOnly = false,
isCommentAssignedOnly = false,
isReadOnly = false,
isReadAssignedOnly = false,
currentUserId = Meteor.userId(),
) {
const memberIndex = this.memberIndex(memberId);
@ -1463,6 +1537,10 @@ Boards.mutations({
[`members.${memberIndex}.isNoComments`]: isNoComments,
[`members.${memberIndex}.isCommentOnly`]: isCommentOnly,
[`members.${memberIndex}.isWorker`]: isWorker,
[`members.${memberIndex}.isNormalAssignedOnly`]: isNormalAssignedOnly,
[`members.${memberIndex}.isCommentAssignedOnly`]: isCommentAssignedOnly,
[`members.${memberIndex}.isReadOnly`]: isReadOnly,
[`members.${memberIndex}.isReadAssignedOnly`]: isReadAssignedOnly,
},
};
},
@ -2372,6 +2450,10 @@ JsonRoutes.add('POST', '/api/boards/:boardId/copy', function(req, res) {
* @param {boolean} isNoComments NoComments capability
* @param {boolean} isCommentOnly CommentsOnly capability
* @param {boolean} isWorker Worker capability
* @param {boolean} isNormalAssignedOnly NormalAssignedOnly capability
* @param {boolean} isCommentAssignedOnly CommentAssignedOnly capability
* @param {boolean} isReadOnly ReadOnly capability
* @param {boolean} isReadAssignedOnly ReadAssignedOnly capability
*/
JsonRoutes.add('POST', '/api/boards/:boardId/members/:memberId', function(
req,
@ -2381,7 +2463,7 @@ JsonRoutes.add('POST', '/api/boards/:boardId/copy', function(req, res) {
Authentication.checkUserId(req.userId);
const boardId = req.params.boardId;
const memberId = req.params.memberId;
const { isAdmin, isNoComments, isCommentOnly, isWorker } = req.body;
const { isAdmin, isNoComments, isCommentOnly, isWorker, isNormalAssignedOnly, isCommentAssignedOnly, isReadOnly, isReadAssignedOnly } = req.body;
const board = ReactiveCache.getBoard(boardId);
function isTrue(data) {
try {
@ -2396,6 +2478,10 @@ JsonRoutes.add('POST', '/api/boards/:boardId/copy', function(req, res) {
isTrue(isNoComments),
isTrue(isCommentOnly),
isTrue(isWorker),
isTrue(isNormalAssignedOnly),
isTrue(isCommentAssignedOnly),
isTrue(isReadOnly),
isTrue(isReadAssignedOnly),
req.userId,
);

View file

@ -2947,6 +2947,10 @@ if (Meteor.isServer) {
* @param {boolean} isNoComments disable comments
* @param {boolean} isCommentOnly only enable comments
* @param {boolean} isWorker is the user a board worker
* @param {boolean} isNormalAssignedOnly only see assigned cards (Normal permission)
* @param {boolean} isCommentAssignedOnly only comment on assigned cards
* @param {boolean} isReadOnly read-only access (no comments or editing)
* @param {boolean} isReadAssignedOnly read-only assigned cards only
* @return_type {_id: string,
* title: string}
*/
@ -2959,7 +2963,7 @@ if (Meteor.isServer) {
const userId = req.params.userId;
const boardId = req.params.boardId;
const action = req.body.action;
const { isAdmin, isNoComments, isCommentOnly, isWorker } = req.body;
const { isAdmin, isNoComments, isCommentOnly, isWorker, isNormalAssignedOnly, isCommentAssignedOnly, isReadOnly, isReadAssignedOnly } = req.body;
let data = ReactiveCache.getUser(userId);
if (data !== undefined) {
if (action === 'add') {
@ -2978,6 +2982,10 @@ if (Meteor.isServer) {
isTrue(isNoComments),
isTrue(isCommentOnly),
isTrue(isWorker),
isTrue(isNormalAssignedOnly),
isTrue(isCommentAssignedOnly),
isTrue(isReadOnly),
isTrue(isReadAssignedOnly),
userId,
);
}