diff options
author | Lauri Ojansivu <x@xet7.org> | 2018-03-20 22:13:18 +0200 |
---|---|---|
committer | Lauri Ojansivu <x@xet7.org> | 2018-03-20 22:13:18 +0200 |
commit | ec1630f8dd3719a15a17328687e5416aed82e874 (patch) | |
tree | 0752c6fe03c7776e9f8b9ed2fc437885b5b36325 /client/components/cards/cardDetails.js | |
parent | 90f3f7ba163ef5d015bc473946b02c23e263a011 (diff) | |
parent | 5e5a5ed9be33fe020b76dfb1ab4b32aec0753a20 (diff) | |
download | wekan-ec1630f8dd3719a15a17328687e5416aed82e874.tar.gz wekan-ec1630f8dd3719a15a17328687e5416aed82e874.tar.bz2 wekan-ec1630f8dd3719a15a17328687e5416aed82e874.zip |
Merge branch 'checklistItems' of https://github.com/andresmanelli/wekan into andresmanelli-checklistItems
Diffstat (limited to 'client/components/cards/cardDetails.js')
-rw-r--r-- | client/components/cards/cardDetails.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/client/components/cards/cardDetails.js b/client/components/cards/cardDetails.js index ab8a6288..77593a74 100644 --- a/client/components/cards/cardDetails.js +++ b/client/components/cards/cardDetails.js @@ -1,4 +1,5 @@ const subManager = new SubsManager(); +const { calculateIndexData } = Utils; BlazeComponent.extendComponent({ mixins() { @@ -66,6 +67,51 @@ BlazeComponent.extendComponent({ onRendered() { if (!Utils.isMiniScreen()) this.scrollParentContainer(); + const $checklistsDom = this.$('.card-checklist-items'); + + $checklistsDom.sortable({ + tolerance: 'pointer', + helper: 'clone', + handle: '.checklist-title', + items: '.js-checklist', + placeholder: 'checklist placeholder', + distance: 7, + start(evt, ui) { + ui.placeholder.height(ui.helper.height()); + EscapeActions.executeUpTo('popup-close'); + }, + stop(evt, ui) { + let prevChecklist = ui.item.prev('.js-checklist').get(0); + if (prevChecklist) { + prevChecklist = Blaze.getData(prevChecklist).checklist; + } + let nextChecklist = ui.item.next('.js-checklist').get(0); + if (nextChecklist) { + nextChecklist = Blaze.getData(nextChecklist).checklist; + } + const sortIndex = calculateIndexData(prevChecklist, nextChecklist, 1); + + $checklistsDom.sortable('cancel'); + const checklist = Blaze.getData(ui.item.get(0)).checklist; + + Checklists.update(checklist._id, { + $set: { + sort: sortIndex.base, + }, + }); + }, + }); + + function userIsMember() { + return Meteor.user() && Meteor.user().isBoardMember(); + } + + // Disable sorting if the current user is not a board member + this.autorun(() => { + if ($checklistsDom.data('sortable')) { + $checklistsDom.sortable('option', 'disabled', !userIsMember()); + } + }); }, onDestroyed() { |