mirror of
https://github.com/wekan/wekan.git
synced 2026-02-04 07:31:47 +01:00
Add copy swimlane functionality
This commit is contained in:
parent
2119a3a51e
commit
4940af0573
7 changed files with 101 additions and 59 deletions
|
|
@ -1,49 +1,28 @@
|
|||
Meteor.methods({
|
||||
copySwimlane(swimlaneId, toBoardId) {
|
||||
check(swimlaneId, String);
|
||||
check(toBoardId, String);
|
||||
|
||||
const swimlane = Swimlanes.findOne(swimlaneId);
|
||||
const toBoard = Boards.findOne(toBoardId);
|
||||
|
||||
if (swimlane && toBoard) {
|
||||
swimlane.copy(toBoardId);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
moveSwimlane(swimlaneId, toBoardId) {
|
||||
check(swimlaneId, String);
|
||||
check(toBoardId, String);
|
||||
|
||||
const swimlane = Swimlanes.findOne(swimlaneId);
|
||||
const fromBoard = Boards.findOne(swimlane.boardId);
|
||||
const toBoard = Boards.findOne(toBoardId);
|
||||
|
||||
if (swimlane && toBoard) {
|
||||
swimlane.lists().forEach(list => {
|
||||
const toList = Lists.findOne({
|
||||
boardId: toBoardId,
|
||||
title: list.title,
|
||||
archived: false,
|
||||
});
|
||||
|
||||
let toListId;
|
||||
if (toList) {
|
||||
toListId = toList._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
|
||||
fromBoard.getDefaultSwimline();
|
||||
swimlane.move(toBoardId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue