summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Hartmayer <hello@hartmayer.com>2020-05-25 21:01:51 +0200
committerMarc Hartmayer <hello@hartmayer.com>2020-05-25 22:48:57 +0200
commit5c02850bc19fd3d049e73d5b7aaa013def6e65e2 (patch)
tree6f3ada2799618700df85bb35ecf66e7dfa6fe951
parent8eafa1ac66fdcf5fb5f0a95aa6cfee454ddad67f (diff)
downloadwekan-5c02850bc19fd3d049e73d5b7aaa013def6e65e2.tar.gz
wekan-5c02850bc19fd3d049e73d5b7aaa013def6e65e2.tar.bz2
wekan-5c02850bc19fd3d049e73d5b7aaa013def6e65e2.zip
Fix move selection
This fixes https://github.com/wekan/wekan/issues/3119.
-rw-r--r--client/components/sidebar/sidebarFilters.js5
-rw-r--r--client/components/swimlanes/swimlanes.jade2
-rw-r--r--models/cards.js42
3 files changed, 46 insertions, 3 deletions
diff --git a/client/components/sidebar/sidebarFilters.js b/client/components/sidebar/sidebarFilters.js
index 0d402ab5..56badba8 100644
--- a/client/components/sidebar/sidebarFilters.js
+++ b/client/components/sidebar/sidebarFilters.js
@@ -157,8 +157,9 @@ Template.disambiguateMultiMemberPopup.events({
});
Template.moveSelectionPopup.events({
- 'click .js-select-list'() {
- mutateSelectedCards('move', this._id);
+ 'click .js-select-list'(event) {
+ // Move the minicard to the end of the target list
+ mutateSelectedCards('moveToEndOfList', { listId: this._id });
EscapeActions.executeUpTo('multiselection');
},
});
diff --git a/client/components/swimlanes/swimlanes.jade b/client/components/swimlanes/swimlanes.jade
index 9b00d9e8..df7fede5 100644
--- a/client/components/swimlanes/swimlanes.jade
+++ b/client/components/swimlanes/swimlanes.jade
@@ -2,7 +2,7 @@ template(name="swimlane")
.swimlane
+swimlaneHeader
unless collapseSwimlane
- .swimlane.js-lists.js-swimlane
+ .swimlane.js-lists.js-swimlane(id="swimlane-{{_id}}")
if isMiniScreen
if currentListIsInThisSwimlane _id
+list(currentList)
diff --git a/models/cards.js b/models/cards.js
index 6d5e23cc..17279e1c 100644
--- a/models/cards.js
+++ b/models/cards.js
@@ -1255,6 +1255,48 @@ Cards.mutations({
};
},
+ moveToEndOfList({ listId } = {}) {
+ let swimlaneId = this.swimlaneId;
+ const boardId = this.boardId;
+ let sortIndex = 0;
+
+ // This should never happen, but there was a bug that was fixed in commit
+ // ea0239538a68e225c867411a4f3e0d27c158383.
+ if (!swimlaneId) {
+ const board = Boards.findOne(boardId);
+ swimlaneId = board.getDefaultSwimline()._id;
+ }
+ // Move the minicard to the end of the target list
+ let parentElementDom = $(`#swimlane-${this.swimlaneId}`).get(0);
+ if (!parentElementDom) parentElementDom = $(':root');
+
+ const lastCardDom = $(parentElementDom)
+ .find(`#js-list-${listId} .js-minicard:last`)
+ .get(0);
+ if (lastCardDom) sortIndex = Utils.calculateIndex(lastCardDom, null).base;
+
+ return this.moveOptionalArgs({
+ boardId: boardId,
+ swimlaneId: swimlaneId,
+ listId: listId,
+ sort: sortIndex,
+ });
+ },
+
+ moveOptionalArgs({ boardId, swimlaneId, listId, sort } = {}) {
+ boardId = boardId ?? this.boardId;
+ swimlaneId = swimlaneId ?? this.swimlaneId;
+ // This should never happen, but there was a bug that was fixed in commit
+ // ea0239538a68e225c867411a4f3e0d27c158383.
+ if (!swimlaneId) {
+ const board = Boards.findOne(boardId);
+ swimlaneId = board.getDefaultSwimline()._id;
+ }
+ listId = listId ?? this.listId;
+ sort = sort ?? this.sort;
+ return this.move(boardId, swimlaneId, listId, sort);
+ },
+
move(boardId, swimlaneId, listId, sort) {
// Copy Custom Fields
if (this.boardId !== boardId) {