summaryrefslogtreecommitdiffstats
path: root/client/components/cards/cardDetails.js
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2018-03-20 22:58:59 +0200
committerLauri Ojansivu <x@xet7.org>2018-03-20 22:58:59 +0200
commit578bdf9e67fd53b39d1c0c9e84fd8fc5ac49b799 (patch)
tree8bb0c9d19a23dfb374a251241ba83f8e7b448bae /client/components/cards/cardDetails.js
parenta7f88d24a18b97a696add1b67e4079a877b433e2 (diff)
parenta7855f3f582d193b0a6dbd70b5da6f59384f9520 (diff)
downloadwekan-578bdf9e67fd53b39d1c0c9e84fd8fc5ac49b799.tar.gz
wekan-578bdf9e67fd53b39d1c0c9e84fd8fc5ac49b799.tar.bz2
wekan-578bdf9e67fd53b39d1c0c9e84fd8fc5ac49b799.zip
Merge branch 'devel'
Diffstat (limited to 'client/components/cards/cardDetails.js')
-rw-r--r--client/components/cards/cardDetails.js46
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() {