mirror of
https://github.com/wekan/wekan.git
synced 2026-02-20 06:58:07 +01:00
Use a method call to move the swimlane server side
This commit is contained in:
parent
aad300613d
commit
ed54c09b48
4 changed files with 83 additions and 66 deletions
52
server/publications/swimlanes.js
Normal file
52
server/publications/swimlanes.js
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
Meteor.methods({
|
||||
moveSwimlane(swimlaneId, toBoardId) {
|
||||
check(swimlaneId, String);
|
||||
check(toBoardId, String);
|
||||
|
||||
const swimlane = Swimlanes.findOne(swimlaneId);
|
||||
const board = Boards.findOne(toBoardId);
|
||||
|
||||
if (swimlane && board) {
|
||||
swimlane.lists().forEach(list => {
|
||||
const boardList = Lists.findOne({
|
||||
boardId: toBoardId,
|
||||
title: list.title,
|
||||
archived: false,
|
||||
});
|
||||
|
||||
let toListId;
|
||||
if (boardList) {
|
||||
toListId = boardList._id;
|
||||
} else {
|
||||
toListId = Lists.insert({
|
||||
title: list.title,
|
||||
boardId: toBoardId,
|
||||
type: list.type,
|
||||
archived: false,
|
||||
wipLimit: list.wipLimit,
|
||||
});
|
||||
}
|
||||
|
||||
Cards.find({
|
||||
listId: list._id,
|
||||
swimlaneId,
|
||||
}).forEach(card => {
|
||||
card.move(toBoardId, swimlaneId, toListId);
|
||||
});
|
||||
});
|
||||
|
||||
Swimlanes.update(swimlaneId, {
|
||||
$set: {
|
||||
boardId: toBoardId,
|
||||
},
|
||||
});
|
||||
|
||||
// make sure there is a default swimlane
|
||||
this.board().getDefaultSwimline();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue