summaryrefslogtreecommitdiffstats
path: root/client/components/cards/checklists.js
diff options
context:
space:
mode:
authorAndrés Manelli <andresmanelli@gmail.com>2018-03-19 16:47:07 -0300
committerAndrés Manelli <andresmanelli@gmail.com>2018-03-19 16:47:07 -0300
commit243af32fc798f161e72eddf9e43053b1ba89d98a (patch)
tree0fca4c42907e17887eb491ff6f5b9cdb17840e5f /client/components/cards/checklists.js
parentca89442f3a62a7a97044a6e572eea70158edadbd (diff)
downloadwekan-243af32fc798f161e72eddf9e43053b1ba89d98a.tar.gz
wekan-243af32fc798f161e72eddf9e43053b1ba89d98a.tar.bz2
wekan-243af32fc798f161e72eddf9e43053b1ba89d98a.zip
Add checklist ordering capability
Diffstat (limited to 'client/components/cards/checklists.js')
-rw-r--r--client/components/cards/checklists.js42
1 files changed, 24 insertions, 18 deletions
diff --git a/client/components/cards/checklists.js b/client/components/cards/checklists.js
index 232cc6e4..d68a1e47 100644
--- a/client/components/cards/checklists.js
+++ b/client/components/cards/checklists.js
@@ -38,26 +38,32 @@ function initSorting(items) {
});
}
-Template.checklists.onRendered(function () {
- const self = BlazeComponent.getComponentForElement(this.firstNode);
- self.itemsDom = this.$('.card-checklist-items');
- initSorting(self.itemsDom);
- self.itemsDom.mousedown(function(evt) {
- evt.stopPropagation();
- });
+BlazeComponent.extendComponent({
+ onRendered() {
+ const self = this;
+ self.itemsDom = this.$('.js-checklist-items');
+ initSorting(self.itemsDom);
+ self.itemsDom.mousedown(function(evt) {
+ evt.stopPropagation();
+ });
+
+ function userIsMember() {
+ return Meteor.user() && Meteor.user().isBoardMember();
+ }
- function userIsMember() {
- return Meteor.user() && Meteor.user().isBoardMember();
- }
+ // Disable sorting if the current user is not a board member
+ self.autorun(() => {
+ const $itemsDom = $(self.itemsDom);
+ if ($itemsDom.data('sortable')) {
+ $(self.itemsDom).sortable('option', 'disabled', !userIsMember());
+ }
+ });
+ },
- // Disable sorting if the current user is not a board member
- self.autorun(() => {
- const $itemsDom = $(self.itemsDom);
- if ($itemsDom.data('sortable')) {
- $(self.itemsDom).sortable('option', 'disabled', !userIsMember());
- }
- });
-});
+ canModifyCard() {
+ return Meteor.user() && Meteor.user().isBoardMember() && !Meteor.user().isCommentOnly();
+ },
+}).register('checklistDetail');
BlazeComponent.extendComponent({