mirror of
https://github.com/wekan/wekan.git
synced 2026-01-06 01:28:49 +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
|
|
@ -202,7 +202,7 @@ Lists.helpers({
|
|||
this.swimlaneId = swimlaneId;
|
||||
|
||||
let _id = null;
|
||||
existingListWithSameName = Lists.findOne({
|
||||
const existingListWithSameName = Lists.findOne({
|
||||
boardId,
|
||||
title: this.title,
|
||||
archived: false,
|
||||
|
|
@ -225,6 +225,35 @@ Lists.helpers({
|
|||
});
|
||||
},
|
||||
|
||||
move(boardId, swimlaneId) {
|
||||
const boardList = Lists.findOne({
|
||||
boardId,
|
||||
title: this.title,
|
||||
archived: false,
|
||||
});
|
||||
let listId;
|
||||
if (boardList) {
|
||||
listId = boardList._id;
|
||||
this.cards().forEach(card => {
|
||||
card.move(boardId, this._id, boardList._id);
|
||||
});
|
||||
} else {
|
||||
console.log('list.title:', this.title);
|
||||
console.log('boardList:', boardList);
|
||||
listId = Lists.insert({
|
||||
title: this.title,
|
||||
boardId,
|
||||
type: this.type,
|
||||
archived: false,
|
||||
wipLimit: this.wipLimit,
|
||||
});
|
||||
}
|
||||
|
||||
this.cards(swimlaneId).forEach(card => {
|
||||
card.move(boardId, swimlaneId, listId);
|
||||
});
|
||||
},
|
||||
|
||||
cards(swimlaneId) {
|
||||
const selector = {
|
||||
listId: this._id,
|
||||
|
|
@ -297,36 +326,6 @@ Lists.mutations({
|
|||
return { $set: { starred: !!enable } };
|
||||
},
|
||||
|
||||
move(boardId, swimlaneId, sort=null) {
|
||||
const mutatedFields = {
|
||||
boardId,
|
||||
swimlaneId,
|
||||
sort,
|
||||
};
|
||||
|
||||
if (this.boardId !== boardId) {
|
||||
mutatedFields.boardId = boardId;
|
||||
}
|
||||
|
||||
if (this.swimlaneId !== swimlaneId) {
|
||||
mutatedFields.swimlaneId = swimlaneId;
|
||||
}
|
||||
|
||||
if (sort !== null && sort !== this.sort) {
|
||||
mutatedFields.sort = sort;
|
||||
}
|
||||
|
||||
if (Object.keys(mutatedFields).length) {
|
||||
this.cards().forEach(card => {
|
||||
card.move(boardId, swimlaneId, this._id);
|
||||
});
|
||||
|
||||
Lists.update(this._id, {
|
||||
$set: mutatedFields,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
archive() {
|
||||
if (this.isTemplateList()) {
|
||||
this.cards().forEach(card => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue