summaryrefslogtreecommitdiffstats
path: root/client/components/cards/cardDetails.js
diff options
context:
space:
mode:
authorNicu Tofan <nicu.tofan@gmail.com>2018-06-19 00:25:43 +0300
committerNicu Tofan <nicu.tofan@gmail.com>2018-06-26 14:32:48 +0300
commitf89de026c414879bdb61a0f3117e92fde6acf5aa (patch)
tree3a52e9e0c22f2322385846d16f30fc8eafc27e51 /client/components/cards/cardDetails.js
parent5f20e56721cd23ef6b65138f1b2aa074d7f830c6 (diff)
downloadwekan-f89de026c414879bdb61a0f3117e92fde6acf5aa.tar.gz
wekan-f89de026c414879bdb61a0f3117e92fde6acf5aa.tar.bz2
wekan-f89de026c414879bdb61a0f3117e92fde6acf5aa.zip
Change order using drag-n-drop for subtasks
Diffstat (limited to 'client/components/cards/cardDetails.js')
-rw-r--r--client/components/cards/cardDetails.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/client/components/cards/cardDetails.js b/client/components/cards/cardDetails.js
index 22dacb70..8d917830 100644
--- a/client/components/cards/cardDetails.js
+++ b/client/components/cards/cardDetails.js
@@ -107,6 +107,41 @@ BlazeComponent.extendComponent({
},
});
+ const $subtasksDom = this.$('.card-subtasks-items');
+
+ $subtasksDom.sortable({
+ tolerance: 'pointer',
+ helper: 'clone',
+ handle: '.subtask-title',
+ items: '.js-subtasks',
+ placeholder: 'subtasks 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-subtasks').get(0);
+ if (prevChecklist) {
+ prevChecklist = Blaze.getData(prevChecklist).subtask;
+ }
+ let nextChecklist = ui.item.next('.js-subtasks').get(0);
+ if (nextChecklist) {
+ nextChecklist = Blaze.getData(nextChecklist).subtask;
+ }
+ const sortIndex = calculateIndexData(prevChecklist, nextChecklist, 1);
+
+ $subtasksDom.sortable('cancel');
+ const subtask = Blaze.getData(ui.item.get(0)).subtask;
+
+ Subtasks.update(subtask._id, {
+ $set: {
+ sort: sortIndex.base,
+ },
+ });
+ },
+ });
+
function userIsMember() {
return Meteor.user() && Meteor.user().isBoardMember();
}
@@ -116,6 +151,9 @@ BlazeComponent.extendComponent({
if ($checklistsDom.data('sortable')) {
$checklistsDom.sortable('option', 'disabled', !userIsMember());
}
+ if ($subtasksDom.data('sortable')) {
+ $subtasksDom.sortable('option', 'disabled', !userIsMember());
+ }
});
},