summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/boards.js29
-rw-r--r--models/users.js10
2 files changed, 38 insertions, 1 deletions
diff --git a/models/boards.js b/models/boards.js
index 857aa963..4e193dc7 100644
--- a/models/boards.js
+++ b/models/boards.js
@@ -185,6 +185,7 @@ Boards.attachSchema(
isActive: true,
isNoComments: false,
isCommentOnly: false,
+ isWorker: false,
},
];
}
@@ -222,6 +223,13 @@ Boards.attachSchema(
type: Boolean,
optional: true,
},
+ 'members.$.isWorker': {
+ /**
+ * Is the member only allowed to move card, assign himself to card and comment
+ */
+ type: Boolean,
+ optional: true,
+ },
permission: {
/**
* visibility of the board
@@ -538,6 +546,7 @@ Boards.helpers({
isActive: true,
isAdmin: false,
isNoComments: true,
+ isWorker: false,
});
},
@@ -547,6 +556,17 @@ Boards.helpers({
isActive: true,
isAdmin: false,
isCommentOnly: true,
+ isWorker: false,
+ });
+ },
+
+ hasWorker(memberId) {
+ return !!_.findWhere(this.members, {
+ userId: memberId,
+ isActive: true,
+ isAdmin: false,
+ isCommentOnly: false,
+ isWorker: true,
});
},
@@ -849,6 +869,7 @@ Boards.mutations({
isActive: true,
isNoComments: false,
isCommentOnly: false,
+ isWorker: false,
},
},
};
@@ -881,6 +902,7 @@ Boards.mutations({
isAdmin,
isNoComments,
isCommentOnly,
+ isWorker,
currentUserId = Meteor.userId(),
) {
const memberIndex = this.memberIndex(memberId);
@@ -894,6 +916,7 @@ Boards.mutations({
[`members.${memberIndex}.isAdmin`]: isAdmin,
[`members.${memberIndex}.isNoComments`]: isNoComments,
[`members.${memberIndex}.isCommentOnly`]: isCommentOnly,
+ [`members.${memberIndex}.isWorker`]: isWorker,
},
};
},
@@ -1281,6 +1304,7 @@ if (Meteor.isServer) {
* @param {boolean} [isActive] is the board active (default true)
* @param {boolean} [isNoComments] disable comments (default false)
* @param {boolean} [isCommentOnly] only enable comments (default false)
+ * @param {boolean} [isWorker] only move cards, assign himself to card and comment (default false)
* @param {string} [permission] "private" board <== Set to "public" if you
* want public Wekan board
* @param {string} [color] the color of the board
@@ -1300,6 +1324,7 @@ if (Meteor.isServer) {
isActive: req.body.isActive || true,
isNoComments: req.body.isNoComments || false,
isCommentOnly: req.body.isCommentOnly || false,
+ isWorker: req.body.isWorker || false,
},
],
permission: req.body.permission || 'private',
@@ -1403,6 +1428,7 @@ if (Meteor.isServer) {
* @param {boolean} isAdmin admin capability
* @param {boolean} isNoComments NoComments capability
* @param {boolean} isCommentOnly CommentsOnly capability
+ * @param {boolean} isWorker Worker capability
*/
JsonRoutes.add('POST', '/api/boards/:boardId/members/:memberId', function(
req,
@@ -1411,7 +1437,7 @@ if (Meteor.isServer) {
try {
const boardId = req.params.boardId;
const memberId = req.params.memberId;
- const { isAdmin, isNoComments, isCommentOnly } = req.body;
+ const { isAdmin, isNoComments, isCommentOnly, isWorker } = req.body;
Authentication.checkBoardAccess(req.userId, boardId);
const board = Boards.findOne({ _id: boardId });
function isTrue(data) {
@@ -1426,6 +1452,7 @@ if (Meteor.isServer) {
isTrue(isAdmin),
isTrue(isNoComments),
isTrue(isCommentOnly),
+ isTrue(isWorker),
req.userId,
);
diff --git a/models/users.js b/models/users.js
index 83a224ba..7e23835c 100644
--- a/models/users.js
+++ b/models/users.js
@@ -352,6 +352,16 @@ if (Meteor.isClient) {
return board && board.hasCommentOnly(this._id);
},
+ isNotWorker() {
+ const board = Boards.findOne(Session.get('currentBoard'));
+ return board && board.hasMember(this._id) && !board.hasWorker(this._id);
+ },
+
+ isWorker() {
+ const board = Boards.findOne(Session.get('currentBoard'));
+ return board && board.hasWorker(this._id);
+ },
+
isBoardAdmin() {
const board = Boards.findOne(Session.get('currentBoard'));
return board && board.hasAdmin(this._id);