diff options
author | Lauri Ojansivu <x@xet7.org> | 2018-02-28 16:35:56 +0200 |
---|---|---|
committer | Lauri Ojansivu <x@xet7.org> | 2018-02-28 16:35:56 +0200 |
commit | daf1a67dc26f48efffca3f6a05fc607184ee7bab (patch) | |
tree | 653bc7d59c88ea1cec03a28d62606d1019287e5a /client/components/swimlanes/swimlanes.js | |
parent | e44c46bcd2513440f70476b7299ae0f830e7c619 (diff) | |
parent | 284fac043b419de1a02edb6a7ec4cd9d49d7cce9 (diff) | |
download | wekan-daf1a67dc26f48efffca3f6a05fc607184ee7bab.tar.gz wekan-daf1a67dc26f48efffca3f6a05fc607184ee7bab.tar.bz2 wekan-daf1a67dc26f48efffca3f6a05fc607184ee7bab.zip |
Merge branch 'devel'
Diffstat (limited to 'client/components/swimlanes/swimlanes.js')
-rw-r--r-- | client/components/swimlanes/swimlanes.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/client/components/swimlanes/swimlanes.js b/client/components/swimlanes/swimlanes.js index 211f84f2..9c3435d6 100644 --- a/client/components/swimlanes/swimlanes.js +++ b/client/components/swimlanes/swimlanes.js @@ -1,4 +1,43 @@ +const { calculateIndex } = Utils; + BlazeComponent.extendComponent({ + onRendered() { + const boardComponent = this.parentComponent(); + const $swimlanesDom = boardComponent.$('.js-swimlanes'); + + $swimlanesDom.sortable({ + tolerance: 'pointer', + appendTo: 'body', + helper: 'clone', + handle: '.js-swimlane-header', + items: '.js-swimlane:not(.placeholder)', + placeholder: 'swimlane placeholder', + distance: 7, + start(evt, ui) { + ui.placeholder.height(ui.helper.height()); + EscapeActions.executeUpTo('popup-close'); + boardComponent.setIsDragging(true); + }, + stop(evt, ui) { + // To attribute the new index number, we need to get the DOM element + // of the previous and the following card -- if any. + const prevSwimlaneDom = ui.item.prev('.js-swimlane').get(0); + const nextSwimlaneDom = ui.item.next('.js-swimlane').get(0); + const sortIndex = calculateIndex(prevSwimlaneDom, nextSwimlaneDom, 1); + + $swimlanesDom.sortable('cancel'); + const swimlaneDomElement = ui.item.get(0); + const swimlane = Blaze.getData(swimlaneDomElement); + + console.log(swimlane._id); + Swimlanes.update(swimlane._id, { + $set: { + sort: sortIndex.base, + }, + }); + }, + }); + }, onCreated() { this.draggingActive = new ReactiveVar(false); |