Add Worker role.

This was originally added at Wekan v3.58,
reverted at Wekan v3.60 because of bugs,
and now after fixes added back.

Thanks to xet7 !

Closes #2788
This commit is contained in:
Lauri Ojansivu 2020-01-05 21:28:14 +02:00
parent 6209b792aa
commit f6f7705f23
19 changed files with 346 additions and 205 deletions

View file

@ -38,6 +38,7 @@ template(name="attachmentsGalery")
| {{_ 'download'}} | {{_ 'download'}}
if currentUser.isBoardMember if currentUser.isBoardMember
unless currentUser.isCommentOnly unless currentUser.isCommentOnly
unless currentUser.isWorker
if isImage if isImage
a(class="{{#if $eq ../coverId _id}}js-remove-cover{{else}}js-add-cover{{/if}}") a(class="{{#if $eq ../coverId _id}}js-remove-cover{{else}}js-add-cover{{/if}}")
i.fa.fa-thumb-tack i.fa.fa-thumb-tack
@ -51,5 +52,6 @@ template(name="attachmentsGalery")
if currentUser.isBoardMember if currentUser.isBoardMember
unless currentUser.isCommentOnly unless currentUser.isCommentOnly
unless currentUser.isWorker
li.attachment-item.add-attachment li.attachment-item.add-attachment
a.js-add-attachment {{_ 'add-attachment' }} a.js-add-attachment {{_ 'add-attachment' }}

View file

@ -97,7 +97,8 @@ Template.dateBadge.helpers({
return ( return (
Meteor.user() && Meteor.user() &&
Meteor.user().isBoardMember() && Meteor.user().isBoardMember() &&
!Meteor.user().isCommentOnly() !Meteor.user().isCommentOnly() &&
!Meteor.user().isWorker()
); );
}, },
}); });

View file

@ -44,6 +44,7 @@ template(name="cardDetails")
+cardReceivedDate +cardReceivedDate
else else
if canModifyCard if canModifyCard
unless currentUser.isWorker
a.js-received-date {{_ 'add'}} a.js-received-date {{_ 'add'}}
.card-details-item.card-details-item-start .card-details-item.card-details-item-start
@ -54,6 +55,7 @@ template(name="cardDetails")
+cardStartDate +cardStartDate
else else
if canModifyCard if canModifyCard
unless currentUser.isWorker
a.js-start-date {{_ 'add'}} a.js-start-date {{_ 'add'}}
.card-details-item.card-details-item-due .card-details-item.card-details-item-due
@ -64,6 +66,7 @@ template(name="cardDetails")
+cardDueDate +cardDueDate
else else
if canModifyCard if canModifyCard
unless currentUser.isWorker
a.js-due-date {{_ 'add'}} a.js-due-date {{_ 'add'}}
.card-details-item.card-details-item-end .card-details-item.card-details-item-end
@ -74,6 +77,7 @@ template(name="cardDetails")
+cardEndDate +cardEndDate
else else
if canModifyCard if canModifyCard
unless currentUser.isWorker
a.js-end-date {{_ 'add'}} a.js-end-date {{_ 'add'}}
.card-details-items .card-details-items
@ -85,6 +89,7 @@ template(name="cardDetails")
+userAvatar(userId=this cardId=../_id) +userAvatar(userId=this cardId=../_id)
| {{! XXX Hack to hide syntaxic coloration /// }} | {{! XXX Hack to hide syntaxic coloration /// }}
if canModifyCard if canModifyCard
unless currentUser.isWorker
a.member.add-member.card-details-item-add-button.js-add-members(title="{{_ 'card-members-title'}}") a.member.add-member.card-details-item-add-button.js-add-members(title="{{_ 'card-members-title'}}")
i.fa.fa-plus i.fa.fa-plus
@ -96,10 +101,14 @@ template(name="cardDetails")
+userAvatarAssignee(userId=this cardId=../_id) +userAvatarAssignee(userId=this cardId=../_id)
| {{! XXX Hack to hide syntaxic coloration /// }} | {{! XXX Hack to hide syntaxic coloration /// }}
if canModifyCard if canModifyCard
a.assignee.add-assignee.card-details-item-add-button.js-add-assignees(title="{{_ 'assignee'}}")
i.fa.fa-plus
if currentUser.isWorker
unless assigneeSelected unless assigneeSelected
a.assignee.add-assignee.card-details-item-add-button.js-add-assignees(title="{{_ 'assignee'}}") a.assignee.add-assignee.card-details-item-add-button.js-add-assignees(title="{{_ 'assignee'}}")
i.fa.fa-plus i.fa.fa-plus
.card-details-item.card-details-item-labels .card-details-item.card-details-item-labels
h3 h3
i.fa.fa-tags i.fa.fa-tags
@ -110,6 +119,7 @@ template(name="cardDetails")
+viewer +viewer
= name = name
if canModifyCard if canModifyCard
unless currentUser.isWorker
a.card-label.add-label.js-add-labels(title="{{_ 'card-labels-title'}}") a.card-label.add-label.js-add-labels(title="{{_ 'card-labels-title'}}")
i.fa.fa-plus i.fa.fa-plus
@ -132,6 +142,7 @@ template(name="cardDetails")
//- XXX We should use "editable" to avoid repetiting ourselves //- XXX We should use "editable" to avoid repetiting ourselves
if canModifyCard if canModifyCard
unless currentUser.isWorker
h3 h3
i.fa.fa-align-left i.fa.fa-align-left
card-details-item-title {{_ 'description'}} card-details-item-title {{_ 'description'}}
@ -165,6 +176,7 @@ template(name="cardDetails")
i.fa.fa-shopping-cart i.fa.fa-shopping-cart
card-details-item-title {{_ 'requested-by'}} card-details-item-title {{_ 'requested-by'}}
if canModifyCard if canModifyCard
unless currentUser.isWorker
+inlinedForm(classNames="js-card-details-requester") +inlinedForm(classNames="js-card-details-requester")
+editCardRequesterForm +editCardRequesterForm
else else
@ -183,6 +195,7 @@ template(name="cardDetails")
i.fa.fa-user-plus i.fa.fa-user-plus
card-details-item-title {{_ 'assigned-by'}} card-details-item-title {{_ 'assigned-by'}}
if canModifyCard if canModifyCard
unless currentUser.isWorker
+inlinedForm(classNames="js-card-details-assigner") +inlinedForm(classNames="js-card-details-assigner")
+editCardAssignerForm +editCardAssignerForm
else else
@ -266,6 +279,7 @@ template(name="cardDetailsActionsPopup")
i.fa.fa-eye-slash i.fa.fa-eye-slash
| {{_ 'watch'}} | {{_ 'watch'}}
if canModifyCard if canModifyCard
unless currentUser.isWorker
hr hr
ul.pop-over-list ul.pop-over-list
//li: a.js-members {{_ 'card-edit-members'}} //li: a.js-members {{_ 'card-edit-members'}}
@ -297,6 +311,7 @@ template(name="cardDetailsActionsPopup")
a.js-move-card-to-bottom a.js-move-card-to-bottom
i.fa.fa-arrow-down i.fa.fa-arrow-down
| {{_ 'moveCardToBottom-title'}} | {{_ 'moveCardToBottom-title'}}
unless currentUser.isWorker
hr hr
ul.pop-over-list ul.pop-over-list
li li
@ -379,6 +394,7 @@ template(name="cardMembersPopup")
i.fa.fa-check i.fa.fa-check
template(name="cardAssigneesPopup") template(name="cardAssigneesPopup")
unless currentUser.isWorker
ul.pop-over-list.js-card-assignee-list ul.pop-over-list.js-card-assignee-list
each board.activeMembers each board.activeMembers
li.item(class="{{#if isCardAssignee}}active{{/if}}") li.item(class="{{#if isCardAssignee}}active{{/if}}")
@ -389,6 +405,16 @@ template(name="cardAssigneesPopup")
| (<span class="username">{{ user.username }}</span>) | (<span class="username">{{ user.username }}</span>)
if isCardAssignee if isCardAssignee
i.fa.fa-check i.fa.fa-check
if currentUser.isWorker
ul.pop-over-list.js-card-assignee-list
li.item(class="{{#if currentUser.isCardAssignee}}active{{/if}}")
a.name.js-select-assignee(href="#")
+userAvatar(userId=currentUser._id)
span.full-name
= currentUser.profile.fullname
| (<span class="username">{{ currentUser.username }}</span>)
if currentUser.isCardAssignee
i.fa.fa-check
template(name="userAvatarAssignee") template(name="userAvatarAssignee")
a.assignee.js-assignee(title="{{userData.profile.fullname}} ({{userData.username}})") a.assignee.js-assignee(title="{{userData.profile.fullname}} ({{userData.username}})")
@ -416,8 +442,10 @@ template(name="cardAssigneePopup")
p.quiet @{{ user.username }} p.quiet @{{ user.username }}
ul.pop-over-list ul.pop-over-list
if currentUser.isNotCommentOnly if currentUser.isNotCommentOnly
unless currentUser.isWorker
li: a.js-remove-assignee {{_ 'remove-member-from-card'}} li: a.js-remove-assignee {{_ 'remove-member-from-card'}}
unless currentUser.isWorker
if $eq currentUser._id user._id if $eq currentUser._id user._id
with currentUser with currentUser
li: a.js-edit-profile {{_ 'edit-profile'}} li: a.js-edit-profile {{_ 'edit-profile'}}

View file

@ -51,7 +51,8 @@ BlazeComponent.extendComponent({
return ( return (
Meteor.user() && Meteor.user() &&
Meteor.user().isBoardMember() && Meteor.user().isBoardMember() &&
!Meteor.user().isCommentOnly() !Meteor.user().isCommentOnly() &&
!Meteor.user().isWorker()
); );
}, },

View file

@ -67,7 +67,8 @@ BlazeComponent.extendComponent({
return ( return (
Meteor.user() && Meteor.user() &&
Meteor.user().isBoardMember() && Meteor.user().isBoardMember() &&
!Meteor.user().isCommentOnly() !Meteor.user().isCommentOnly() &&
!Meteor.user().isWorker()
); );
}, },
}).register('checklistDetail'); }).register('checklistDetail');
@ -120,7 +121,8 @@ BlazeComponent.extendComponent({
return ( return (
Meteor.user() && Meteor.user() &&
Meteor.user().isBoardMember() && Meteor.user().isBoardMember() &&
!Meteor.user().isCommentOnly() !Meteor.user().isCommentOnly() &&
!Meteor.user().isWorker()
); );
}, },
@ -228,7 +230,8 @@ Template.checklistItemDetail.helpers({
return ( return (
Meteor.user() && Meteor.user() &&
Meteor.user().isBoardMember() && Meteor.user().isBoardMember() &&
!Meteor.user().isCommentOnly() !Meteor.user().isCommentOnly() &&
!Meteor.user().isWorker()
); );
}, },
}); });

View file

@ -3,7 +3,8 @@ BlazeComponent.extendComponent({
return ( return (
Meteor.user() && Meteor.user() &&
Meteor.user().isBoardMember() && Meteor.user().isBoardMember() &&
!Meteor.user().isCommentOnly() !Meteor.user().isCommentOnly() &&
!Meteor.user().isWorker()
); );
}, },
}).register('subtaskDetail'); }).register('subtaskDetail');
@ -55,7 +56,8 @@ BlazeComponent.extendComponent({
return ( return (
Meteor.user() && Meteor.user() &&
Meteor.user().isBoardMember() && Meteor.user().isBoardMember() &&
!Meteor.user().isCommentOnly() !Meteor.user().isCommentOnly() &&
!Meteor.user().isWorker()
); );
}, },
@ -154,7 +156,8 @@ Template.subtaskItemDetail.helpers({
return ( return (
Meteor.user() && Meteor.user() &&
Meteor.user().isBoardMember() && Meteor.user().isBoardMember() &&
!Meteor.user().isCommentOnly() !Meteor.user().isCommentOnly() &&
!Meteor.user().isWorker()
); );
}, },
}); });

View file

@ -189,7 +189,8 @@ BlazeComponent.extendComponent({
!this.reachedWipLimit() && !this.reachedWipLimit() &&
Meteor.user() && Meteor.user() &&
Meteor.user().isBoardMember() && Meteor.user().isBoardMember() &&
!Meteor.user().isCommentOnly() !Meteor.user().isCommentOnly() &&
!Meteor.user().isWorker()
); );
}, },

View file

@ -10,7 +10,7 @@ template(name="listHeader")
a.list-header-left-icon.fa.fa-angle-left.js-unselect-list a.list-header-left-icon.fa.fa-angle-left.js-unselect-list
h2.list-header-name( h2.list-header-name(
title="{{ moment modifiedAt 'LLL' }}" title="{{ moment modifiedAt 'LLL' }}"
class="{{#if currentUser.isBoardMember}}{{#unless currentUser.isCommentOnly}}js-open-inlined-form is-editable{{/unless}}{{/if}}") class="{{#if currentUser.isBoardMember}}{{#unless currentUser.isCommentOnly}}{{#unless currentUser.isWorker}}js-open-inlined-form is-editable{{/unless}}{{/unless}}{{/if}}")
+viewer +viewer
= title = title
if wipLimit.enabled if wipLimit.enabled
@ -65,6 +65,7 @@ template(name="listActionPopup")
i.fa.fa-eye-slash i.fa.fa-eye-slash
| {{_ 'watch'}} | {{_ 'watch'}}
unless currentUser.isCommentOnly unless currentUser.isCommentOnly
unless currentUser.isWorker
ul.pop-over-list ul.pop-over-list
li li
a.js-set-color-list a.js-set-color-list
@ -82,6 +83,7 @@ template(name="listActionPopup")
a.js-set-wip-limit a.js-set-wip-limit
i.fa.fa-ban i.fa.fa-ban
| {{#if isWipLimitEnabled }}{{_ 'edit-wip-limit'}}{{else}}{{_ 'setWipLimitPopup-title'}}{{/if}} | {{#if isWipLimitEnabled }}{{_ 'edit-wip-limit'}}{{else}}{{_ 'setWipLimitPopup-title'}}{{/if}}
unless currentUser.isWorker
hr hr
ul.pop-over-list ul.pop-over-list
li li
@ -114,6 +116,7 @@ template(name="listMorePopup")
input.inline-input(type="text" readonly value="{{ rootUrl }}") input.inline-input(type="text" readonly value="{{ rootUrl }}")
| {{_ 'added'}} | {{_ 'added'}}
span.date(title=list.createdAt) {{ moment createdAt 'LLL' }} span.date(title=list.createdAt) {{ moment createdAt 'LLL' }}
unless currentUser.isWorker
a.js-delete {{_ 'delete'}} a.js-delete {{_ 'delete'}}
template(name="listDeletePopup") template(name="listDeletePopup")

View file

@ -9,9 +9,10 @@ BlazeComponent.extendComponent({
canSeeAddCard() { canSeeAddCard() {
const list = Template.currentData(); const list = Template.currentData();
return ( return (
!list.getWipLimit('enabled') || (!list.getWipLimit('enabled') ||
list.getWipLimit('soft') || list.getWipLimit('soft') ||
!this.reachedWipLimit() !this.reachedWipLimit()) &&
!Meteor.user().isWorker()
); );
}, },

View file

@ -40,6 +40,7 @@ template(name="membersWidget")
i.fa.fa-users i.fa.fa-users
| {{_ 'members'}} | {{_ 'members'}}
unless currentUser.isCommentOnly unless currentUser.isCommentOnly
unless currentUser.isWorker
a.board-header-btn.js-open-board-menu(title="{{_ 'boardMenuPopup-title'}}").right a.board-header-btn.js-open-board-menu(title="{{_ 'boardMenuPopup-title'}}").right
i.board-header-btn-icon.fa.fa-cog i.board-header-btn-icon.fa.fa-cog
@ -164,6 +165,7 @@ template(name="outgoingWebhooksPopup")
template(name="boardMenuPopup") template(name="boardMenuPopup")
ul.pop-over-list ul.pop-over-list
if isNotWorker
li: a.js-custom-fields {{_ 'custom-fields'}} li: a.js-custom-fields {{_ 'custom-fields'}}
li li
a.js-open-archives a.js-open-archives
@ -246,7 +248,7 @@ template(name="labelsWidget")
.board-widget-content .board-widget-content
each currentBoard.labels each currentBoard.labels
a.card-label(class="card-label-{{color}}" a.card-label(class="card-label-{{color}}"
class="{{#if currentUser.isNotCommentOnly}}js-label{{/if}}") class="{{#if currentUser.isNotCommentOnly}}{{#if currentUser.isNotWorker}}js-label{{/if}}{{/if}}")
span.card-label-name span.card-label-name
+viewer +viewer
= name = name
@ -275,6 +277,7 @@ template(name="memberPopup")
a.js-change-role a.js-change-role
| {{_ 'change-permissions'}} | {{_ 'change-permissions'}}
span.quiet (#{memberType}) span.quiet (#{memberType})
unless currentUser.isWorker
li li
if $eq currentUser._id userId if $eq currentUser._id userId
a.js-leave-member {{_ 'leave-board'}} a.js-leave-member {{_ 'leave-board'}}
@ -343,6 +346,12 @@ template(name="changePermissionsPopup")
if isCommentOnly if isCommentOnly
i.fa.fa-check i.fa.fa-check
span.sub-name {{_ 'comment-only-desc'}} span.sub-name {{_ 'comment-only-desc'}}
li
a(class="{{#if isLastAdmin}}disabled{{else}}js-set-worker{{/if}}")
| {{_ 'worker'}}
if isWorker
i.fa.fa-check
span.sub-name {{_ 'worker-desc'}}
if isLastAdmin if isLastAdmin
hr hr
p.quiet.bottom {{_ 'last-admin-desc'}} p.quiet.bottom {{_ 'last-admin-desc'}}

View file

@ -161,10 +161,13 @@ Template.memberPopup.helpers({
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); const noComments = currentBoard.hasNoComments(this.userId);
const worker = currentBoard.hasWorker(this.userId);
if (commentOnly) { if (commentOnly) {
return TAPi18n.__('comment-only').toLowerCase(); return TAPi18n.__('comment-only').toLowerCase();
} else if (noComments) { } else if (noComments) {
return TAPi18n.__('no-comments').toLowerCase(); return TAPi18n.__('no-comments').toLowerCase();
} else if (worker) {
return TAPi18n.__('worker').toLowerCase();
} else { } else {
return TAPi18n.__(type).toLowerCase(); return TAPi18n.__(type).toLowerCase();
} }
@ -267,6 +270,14 @@ Template.membersWidget.helpers({
const user = Meteor.user(); const user = Meteor.user();
return user && user.isInvitedTo(Session.get('currentBoard')); return user && user.isInvitedTo(Session.get('currentBoard'));
}, },
isWorker() {
const user = Meteor.user();
if (user) {
return Meteor.call(Boards.hasWorker(user.memberId));
} else {
return false;
}
},
}); });
Template.membersWidget.events({ Template.membersWidget.events({
@ -644,7 +655,7 @@ BlazeComponent.extendComponent({
}).register('addMemberPopup'); }).register('addMemberPopup');
Template.changePermissionsPopup.events({ Template.changePermissionsPopup.events({
'click .js-set-admin, click .js-set-normal, click .js-set-no-comments, click .js-set-comment-only'( 'click .js-set-admin, click .js-set-normal, click .js-set-no-comments, click .js-set-comment-only, click .js-set-worker'(
event, event,
) { ) {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Boards.findOne(Session.get('currentBoard'));
@ -654,11 +665,13 @@ Template.changePermissionsPopup.events({
'js-set-comment-only', 'js-set-comment-only',
); );
const isNoComments = $(event.currentTarget).hasClass('js-set-no-comments'); const isNoComments = $(event.currentTarget).hasClass('js-set-no-comments');
const isWorker = $(event.currentTarget).hasClass('js-set-worker');
currentBoard.setMemberPermission( currentBoard.setMemberPermission(
memberId, memberId,
isAdmin, isAdmin,
isNoComments, isNoComments,
isCommentOnly, isCommentOnly,
isWorker,
); );
Popup.back(1); Popup.back(1);
}, },
@ -675,7 +688,8 @@ Template.changePermissionsPopup.helpers({
return ( return (
!currentBoard.hasAdmin(this.userId) && !currentBoard.hasAdmin(this.userId) &&
!currentBoard.hasNoComments(this.userId) && !currentBoard.hasNoComments(this.userId) &&
!currentBoard.hasCommentOnly(this.userId) !currentBoard.hasCommentOnly(this.userId) &&
!currentBoard.hasWorker(this.userId)
); );
}, },
@ -695,6 +709,13 @@ Template.changePermissionsPopup.helpers({
); );
}, },
isWorker() {
const currentBoard = Boards.findOne(Session.get('currentBoard'));
return (
!currentBoard.hasAdmin(this.userId) && currentBoard.hasWorker(this.userId)
);
},
isLastAdmin() { isLastAdmin() {
const currentBoard = Boards.findOne(Session.get('currentBoard')); const currentBoard = Boards.findOne(Session.get('currentBoard'));
return ( return (

View file

@ -2,6 +2,7 @@ template(name="archivesSidebar")
if isArchiveReady.get if isArchiveReady.get
+basicTabs(tabs=tabs) +basicTabs(tabs=tabs)
+tabContent(slug="cards") +tabContent(slug="cards")
unless isWorker
p.quiet p.quiet
a.js-restore-all-cards {{_ 'restore-all'}} a.js-restore-all-cards {{_ 'restore-all'}}
| - | -
@ -10,6 +11,7 @@ template(name="archivesSidebar")
.minicard-wrapper.js-minicard .minicard-wrapper.js-minicard
+minicard(this) +minicard(this)
if currentUser.isBoardMember if currentUser.isBoardMember
unless isWorker
p.quiet p.quiet
a.js-restore-card {{_ 'restore'}} a.js-restore-card {{_ 'restore'}}
| - | -
@ -20,6 +22,7 @@ template(name="archivesSidebar")
p.no-items-message {{_ 'no-archived-cards'}} p.no-items-message {{_ 'no-archived-cards'}}
+tabContent(slug="lists") +tabContent(slug="lists")
unless isWorker
p.quiet p.quiet
a.js-restore-all-lists {{_ 'restore-all'}} a.js-restore-all-lists {{_ 'restore-all'}}
| - | -
@ -29,6 +32,7 @@ template(name="archivesSidebar")
li.archived-lists-item li.archived-lists-item
= title = title
if currentUser.isBoardMember if currentUser.isBoardMember
unless isWorker
p.quiet p.quiet
a.js-restore-list {{_ 'restore'}} a.js-restore-list {{_ 'restore'}}
| - | -
@ -37,6 +41,7 @@ template(name="archivesSidebar")
li.no-items-message {{_ 'no-archived-lists'}} li.no-items-message {{_ 'no-archived-lists'}}
+tabContent(slug="swimlanes") +tabContent(slug="swimlanes")
unless isWorker
p.quiet p.quiet
a.js-restore-all-swimlanes {{_ 'restore-all'}} a.js-restore-all-swimlanes {{_ 'restore-all'}}
| - | -
@ -46,6 +51,7 @@ template(name="archivesSidebar")
li.archived-lists-item li.archived-lists-item
= title = title
if currentUser.isBoardMember if currentUser.isBoardMember
unless isWorker
p.quiet p.quiet
a.js-restore-swimlane {{_ 'restore'}} a.js-restore-swimlane {{_ 'restore'}}
| - | -

View file

@ -139,3 +139,12 @@ BlazeComponent.extendComponent({
]; ];
}, },
}).register('archivesSidebar'); }).register('archivesSidebar');
Template.archivesSidebar.helpers({
isWorker() {
const currentBoard = Boards.findOne(Session.get('currentBoard'));
return (
!currentBoard.hasAdmin(this.userId) && currentBoard.hasWorker(this.userId)
);
},
});

View file

@ -43,6 +43,7 @@ template(name="listsGroup")
+addListForm +addListForm
template(name="addListForm") template(name="addListForm")
unless currentUser.isWorker
.list.list-composer.js-list-composer(class="{{#if isMiniScreen}}mini-list{{/if}}") .list.list-composer.js-list-composer(class="{{#if isMiniScreen}}mini-list{{/if}}")
.list-header-add .list-header-add
+inlinedForm(autoclose=false) +inlinedForm(autoclose=false)

View file

@ -94,7 +94,8 @@ function initSortable(boardComponent, $listsDom) {
return ( return (
Meteor.user() && Meteor.user() &&
Meteor.user().isBoardMember() && Meteor.user().isBoardMember() &&
!Meteor.user().isCommentOnly() !Meteor.user().isCommentOnly() &&
!Meteor.user().isWorker()
); );
} }
@ -131,6 +132,15 @@ function initSortable(boardComponent, $listsDom) {
// MultiSelection.isActive() || !userIsMember(), // MultiSelection.isActive() || !userIsMember(),
); );
} }
$listsDom.sortable(
'option',
'disabled',
// Disable drag-dropping when user is not member
Meteor.user().isWorker(),
// Not disable drag-dropping while in multi-selection mode
// MultiSelection.isActive() || !userIsMember(),
);
}); });
} }
@ -282,7 +292,8 @@ Template.swimlane.helpers({
return ( return (
Meteor.user() && Meteor.user() &&
Meteor.user().isBoardMember() && Meteor.user().isBoardMember() &&
!Meteor.user().isCommentOnly() !Meteor.user().isCommentOnly() &&
!Meteor.user().isWorker()
); );
}, },
}); });

View file

@ -73,6 +73,7 @@ template(name="cardMemberPopup")
p.quiet @{{ user.username }} p.quiet @{{ user.username }}
ul.pop-over-list ul.pop-over-list
if currentUser.isNotCommentOnly if currentUser.isNotCommentOnly
if currentUser.isNotWorker
li: a.js-remove-member {{_ 'remove-member-from-card'}} li: a.js-remove-member {{_ 'remove-member-from-card'}}
if $eq currentUser._id user._id if $eq currentUser._id user._id

View file

@ -39,6 +39,7 @@ template(name="memberMenuPopup")
a.js-go-setting(href="{{pathFor 'setting'}}") a.js-go-setting(href="{{pathFor 'setting'}}")
i.fa.fa-lock i.fa.fa-lock
| {{_ 'admin-panel'}} | {{_ 'admin-panel'}}
unless currentUser.isWorker
hr hr
ul.pop-over-list ul.pop-over-list
li li
@ -109,6 +110,7 @@ template(name="changeSettingsPopup")
| {{_ 'show-desktop-drag-handles'}} | {{_ 'show-desktop-drag-handles'}}
if showDesktopDragHandles if showDesktopDragHandles
i.fa.fa-check i.fa.fa-check
unless currentUser.isWorker
li li
label.bold label.bold
i.fa.fa-sort-numeric-asc i.fa.fa-sort-numeric-asc
@ -117,5 +119,6 @@ template(name="changeSettingsPopup")
input.js-apply-show-cards-at.left(type="submit" value="{{_ 'apply'}}") input.js-apply-show-cards-at.left(type="submit" value="{{_ 'apply'}}")
template(name="userDeletePopup") template(name="userDeletePopup")
unless currentUser.isWorker
p {{_ 'delete-user-confirm-popup'}} p {{_ 'delete-user-confirm-popup'}}
button.js-confirm.negate.full(type="submit") {{_ 'delete'}} button.js-confirm.negate.full(type="submit") {{_ 'delete'}}

View file

@ -185,6 +185,7 @@ Boards.attachSchema(
isActive: true, isActive: true,
isNoComments: false, isNoComments: false,
isCommentOnly: false, isCommentOnly: false,
isWorker: false,
}, },
]; ];
} }
@ -222,6 +223,13 @@ Boards.attachSchema(
type: Boolean, type: Boolean,
optional: true, optional: true,
}, },
'members.$.isWorker': {
/**
* Is the member only allowed to move card, assign himself to card and comment
*/
type: Boolean,
optional: true,
},
permission: { permission: {
/** /**
* visibility of the board * visibility of the board
@ -538,6 +546,7 @@ Boards.helpers({
isActive: true, isActive: true,
isAdmin: false, isAdmin: false,
isNoComments: true, isNoComments: true,
isWorker: false,
}); });
}, },
@ -547,6 +556,17 @@ Boards.helpers({
isActive: true, isActive: true,
isAdmin: false, isAdmin: false,
isCommentOnly: true, 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, isActive: true,
isNoComments: false, isNoComments: false,
isCommentOnly: false, isCommentOnly: false,
isWorker: false,
}, },
}, },
}; };
@ -881,6 +902,7 @@ Boards.mutations({
isAdmin, isAdmin,
isNoComments, isNoComments,
isCommentOnly, isCommentOnly,
isWorker,
currentUserId = Meteor.userId(), currentUserId = Meteor.userId(),
) { ) {
const memberIndex = this.memberIndex(memberId); const memberIndex = this.memberIndex(memberId);
@ -894,6 +916,7 @@ Boards.mutations({
[`members.${memberIndex}.isAdmin`]: isAdmin, [`members.${memberIndex}.isAdmin`]: isAdmin,
[`members.${memberIndex}.isNoComments`]: isNoComments, [`members.${memberIndex}.isNoComments`]: isNoComments,
[`members.${memberIndex}.isCommentOnly`]: isCommentOnly, [`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} [isActive] is the board active (default true)
* @param {boolean} [isNoComments] disable comments (default false) * @param {boolean} [isNoComments] disable comments (default false)
* @param {boolean} [isCommentOnly] only enable 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 * @param {string} [permission] "private" board <== Set to "public" if you
* want public Wekan board * want public Wekan board
* @param {string} [color] the color of the board * @param {string} [color] the color of the board
@ -1300,6 +1324,7 @@ if (Meteor.isServer) {
isActive: req.body.isActive || true, isActive: req.body.isActive || true,
isNoComments: req.body.isNoComments || false, isNoComments: req.body.isNoComments || false,
isCommentOnly: req.body.isCommentOnly || false, isCommentOnly: req.body.isCommentOnly || false,
isWorker: req.body.isWorker || false,
}, },
], ],
permission: req.body.permission || 'private', permission: req.body.permission || 'private',
@ -1403,6 +1428,7 @@ if (Meteor.isServer) {
* @param {boolean} isAdmin admin capability * @param {boolean} isAdmin admin capability
* @param {boolean} isNoComments NoComments capability * @param {boolean} isNoComments NoComments capability
* @param {boolean} isCommentOnly CommentsOnly capability * @param {boolean} isCommentOnly CommentsOnly capability
* @param {boolean} isWorker Worker capability
*/ */
JsonRoutes.add('POST', '/api/boards/:boardId/members/:memberId', function( JsonRoutes.add('POST', '/api/boards/:boardId/members/:memberId', function(
req, req,
@ -1411,7 +1437,7 @@ if (Meteor.isServer) {
try { try {
const boardId = req.params.boardId; const boardId = req.params.boardId;
const memberId = req.params.memberId; const memberId = req.params.memberId;
const { isAdmin, isNoComments, isCommentOnly } = req.body; const { isAdmin, isNoComments, isCommentOnly, isWorker } = req.body;
Authentication.checkBoardAccess(req.userId, boardId); Authentication.checkBoardAccess(req.userId, boardId);
const board = Boards.findOne({ _id: boardId }); const board = Boards.findOne({ _id: boardId });
function isTrue(data) { function isTrue(data) {
@ -1426,6 +1452,7 @@ if (Meteor.isServer) {
isTrue(isAdmin), isTrue(isAdmin),
isTrue(isNoComments), isTrue(isNoComments),
isTrue(isCommentOnly), isTrue(isCommentOnly),
isTrue(isWorker),
req.userId, req.userId,
); );

View file

@ -352,6 +352,16 @@ if (Meteor.isClient) {
return board && board.hasCommentOnly(this._id); 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() { isBoardAdmin() {
const board = Boards.findOne(Session.get('currentBoard')); const board = Boards.findOne(Session.get('currentBoard'));
return board && board.hasAdmin(this._id); return board && board.hasAdmin(this._id);