diff options
author | Andrés Manelli <andresmanelli@gmail.com> | 2018-02-27 20:11:43 -0300 |
---|---|---|
committer | Andrés Manelli <andresmanelli@gmail.com> | 2018-02-27 20:11:43 -0300 |
commit | 37c94622e476f50bf2387bc8b140454d66200e78 (patch) | |
tree | 4d57b6c4300411b9601825ed8030c2c985e2a053 /client/components/swimlanes/swimlanes.js | |
parent | c4fa9010f34966b633c7bf7e46ad49fc101127c9 (diff) | |
download | wekan-37c94622e476f50bf2387bc8b140454d66200e78.tar.gz wekan-37c94622e476f50bf2387bc8b140454d66200e78.tar.bz2 wekan-37c94622e476f50bf2387bc8b140454d66200e78.zip |
Allow swimlanes reordering
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); |