summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorPeter Verraedt <peter.verraedt@kuleuven.be>2020-01-22 12:09:26 +0100
committerPeter Verraedt <peter.verraedt@kuleuven.be>2020-01-23 15:12:18 +0100
commit4b56bbfe6dd1c16ac8d2cc8da91dc55cff60177e (patch)
treee5241c89d9d9b00402a5a9c48127621df0b4e177 /server
parent70f5326099dc9cfbf1b62d2dcb6ed09aa28174b3 (diff)
downloadwekan-4b56bbfe6dd1c16ac8d2cc8da91dc55cff60177e.tar.gz
wekan-4b56bbfe6dd1c16ac8d2cc8da91dc55cff60177e.tar.bz2
wekan-4b56bbfe6dd1c16ac8d2cc8da91dc55cff60177e.zip
Add rule action to move cards to other boards
Fixes #1996
Diffstat (limited to 'server')
-rw-r--r--server/rulesHelper.js74
1 files changed, 52 insertions, 22 deletions
diff --git a/server/rulesHelper.js b/server/rulesHelper.js
index cf278c52..63e330ab 100644
--- a/server/rulesHelper.js
+++ b/server/rulesHelper.js
@@ -42,35 +42,65 @@ RulesHelper = {
performAction(activity, action) {
const card = Cards.findOne({ _id: activity.cardId });
const boardId = activity.boardId;
- if (action.actionType === 'moveCardToTop') {
- let listId;
+ if (
+ action.actionType === 'moveCardToTop' ||
+ action.actionType === 'moveCardToBottom'
+ ) {
let list;
- if (action.listTitle === '*') {
- listId = card.listId;
+ let listId;
+ if (action.listName === '*') {
list = card.list();
+ if (boardId !== action.boardId) {
+ list = Lists.findOne({ title: list.title, boardId: action.boardId });
+ }
} else {
- list = Lists.findOne({ title: action.listTitle, boardId });
- listId = list._id;
+ list = Lists.findOne({
+ title: action.listName,
+ boardId: action.boardId,
+ });
}
- const minOrder = _.min(
- list.cardsUnfiltered(card.swimlaneId).map(c => c.sort),
- );
- card.move(boardId, card.swimlaneId, listId, minOrder - 1);
- }
- if (action.actionType === 'moveCardToBottom') {
- let listId;
- let list;
- if (action.listTitle === '*') {
- listId = card.listId;
- list = card.list();
+ if (list === undefined) {
+ listId = '';
} else {
- list = Lists.findOne({ title: action.listTitle, boardId });
listId = list._id;
}
- const maxOrder = _.max(
- list.cardsUnfiltered(card.swimlaneId).map(c => c.sort),
- );
- card.move(boardId, card.swimlaneId, listId, maxOrder + 1);
+
+ let swimlane;
+ let swimlaneId;
+ if (action.swimlaneName === '*') {
+ swimlane = Swimlanes.findOne(card.swimlaneId);
+ if (boardId !== action.boardId) {
+ swimlane = Swimlanes.findOne({
+ title: swimlane.title,
+ boardId: action.boardId,
+ });
+ }
+ } else {
+ swimlane = Swimlanes.findOne({
+ title: action.swimlaneName,
+ boardId: action.boardId,
+ });
+ }
+ if (swimlane === undefined) {
+ swimlaneId = Swimlanes.findOne({
+ title: 'Default',
+ boardId: action.boardId,
+ })._id;
+ } else {
+ swimlaneId = swimlane._id;
+ }
+
+ if (action.actionType === 'moveCardToTop') {
+ const minOrder = _.min(
+ list.cardsUnfiltered(swimlaneId).map(c => c.sort),
+ );
+ card.move(action.boardId, swimlaneId, listId, minOrder - 1);
+ } else {
+ const maxOrder = _.max(
+ list.cardsUnfiltered(swimlaneId).map(c => c.sort),
+ );
+ card.move(action.boardId, swimlaneId, listId, maxOrder + 1);
+ }
}
if (action.actionType === 'sendEmail') {
const to = action.emailTo;