summaryrefslogtreecommitdiffstats
path: root/client/components
diff options
context:
space:
mode:
authorMarc Hartmayer <hello@hartmayer.com>2020-05-23 17:25:45 +0200
committerMarc Hartmayer <hello@hartmayer.com>2020-05-23 17:35:22 +0200
commit64fa02cdf5d311329acbbfe63eb309e9c253b57d (patch)
tree2766dfb282450131ad10e46d197954f73c908a19 /client/components
parent94e47401cb54c501682d0fa29221e7fc288820d6 (diff)
downloadwekan-64fa02cdf5d311329acbbfe63eb309e9c253b57d.tar.gz
wekan-64fa02cdf5d311329acbbfe63eb309e9c253b57d.tar.bz2
wekan-64fa02cdf5d311329acbbfe63eb309e9c253b57d.zip
Change the swimlaneid of a card only if a new target swimlaneid is selected
Fixes the issue https://github.com/wekan/wekan/issues/2757. While at it, fix the same issue also for multi selection.
Diffstat (limited to 'client/components')
-rw-r--r--client/components/lists/list.js24
1 files changed, 14 insertions, 10 deletions
diff --git a/client/components/lists/list.js b/client/components/lists/list.js
index 839304f8..5c315588 100644
--- a/client/components/lists/list.js
+++ b/client/components/lists/list.js
@@ -74,18 +74,16 @@ BlazeComponent.extendComponent({
const sortIndex = calculateIndex(prevCardDom, nextCardDom, nCards);
const listId = Blaze.getData(ui.item.parents('.list').get(0))._id;
const currentBoard = Boards.findOne(Session.get('currentBoard'));
- let swimlaneId = '';
+ const defaultSwimlaneId = currentBoard.getDefaultSwimline()._id;
+ let targetSwimlaneId = null;
+
+ // only set a new swimelane ID if the swimlanes view is active
if (
Utils.boardView() === 'board-view-swimlanes' ||
currentBoard.isTemplatesBoard()
)
- swimlaneId = Blaze.getData(ui.item.parents('.swimlane').get(0))._id;
- else if (
- Utils.boardView() === 'board-view-lists' ||
- Utils.boardView() === 'board-view-cal' ||
- !Utils.boardView
- )
- swimlaneId = currentBoard.getDefaultSwimline()._id;
+ targetSwimlaneId = Blaze.getData(ui.item.parents('.swimlane').get(0))
+ ._id;
// Normally the jquery-ui sortable library moves the dragged DOM element
// to its new position, which disrupts Blaze reactive updates mechanism
@@ -98,9 +96,12 @@ BlazeComponent.extendComponent({
if (MultiSelection.isActive()) {
Cards.find(MultiSelection.getMongoSelector()).forEach((card, i) => {
+ const newSwimlaneId = targetSwimlaneId
+ ? targetSwimlaneId
+ : card.swimlaneId || defaultSwimlaneId;
card.move(
currentBoard._id,
- swimlaneId,
+ newSwimlaneId,
listId,
sortIndex.base + i * sortIndex.increment,
);
@@ -108,7 +109,10 @@ BlazeComponent.extendComponent({
} else {
const cardDomElement = ui.item.get(0);
const card = Blaze.getData(cardDomElement);
- card.move(currentBoard._id, swimlaneId, listId, sortIndex.base);
+ const newSwimlaneId = targetSwimlaneId
+ ? targetSwimlaneId
+ : card.swimlaneId || defaultSwimlaneId;
+ card.move(currentBoard._id, newSwimlaneId, listId, sortIndex.base);
}
boardComponent.setIsDragging(false);
},