summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2020-05-25 23:50:51 +0300
committerGitHub <noreply@github.com>2020-05-25 23:50:51 +0300
commitfd0afd7b055e31bdabb50c827dc5656baab15389 (patch)
tree730253c74cbd5e828d522a1214fb52c1bc76c0be /models
parent1f450df1afc7d882a3268273b2b10e3beb6aa8bb (diff)
parent5c02850bc19fd3d049e73d5b7aaa013def6e65e2 (diff)
downloadwekan-fd0afd7b055e31bdabb50c827dc5656baab15389.tar.gz
wekan-fd0afd7b055e31bdabb50c827dc5656baab15389.tar.bz2
wekan-fd0afd7b055e31bdabb50c827dc5656baab15389.zip
Merge pull request #3120 from marc1006/issue_3119
Fix move selection
Diffstat (limited to 'models')
-rw-r--r--models/cards.js42
1 files changed, 42 insertions, 0 deletions
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) {