mirror of
https://github.com/wekan/wekan.git
synced 2025-04-22 04:57:07 -04:00
Add move() methods to Swimlanes and Lists collections
This commit is contained in:
parent
3ce3612047
commit
59a3ac1f37
3 changed files with 58 additions and 2 deletions
|
@ -1527,14 +1527,17 @@ Cards.mutations({
|
|||
return this.move(boardId, swimlaneId, listId, sort);
|
||||
},
|
||||
|
||||
move(boardId, swimlaneId, listId, sort) {
|
||||
move(boardId, swimlaneId, listId, sort=null) {
|
||||
const mutatedFields = {
|
||||
boardId,
|
||||
swimlaneId,
|
||||
listId,
|
||||
sort,
|
||||
};
|
||||
|
||||
if (sort !== null) {
|
||||
mutatedFields.sort = sort;
|
||||
}
|
||||
|
||||
// we must only copy the labels and custom fields if the target board
|
||||
// differs from the source board
|
||||
if (this.boardId !== boardId) {
|
||||
|
|
|
@ -297,6 +297,36 @@ 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 => {
|
||||
|
|
|
@ -269,6 +269,29 @@ Swimlanes.mutations({
|
|||
return { $set: { archived: true, archivedAt: new Date() } };
|
||||
},
|
||||
|
||||
move(boardId, sort=null) {
|
||||
const mutatedFields = {};
|
||||
|
||||
if (this.boardId !== boardId) {
|
||||
mutatedFields.boardId = boardId;
|
||||
}
|
||||
|
||||
if (sort !== null && sort !== this.sort) {
|
||||
mutatedFields.sort = sort;
|
||||
}
|
||||
|
||||
if (Object.keys(mutatedFields).length) {
|
||||
this.lists().forEach(list => {
|
||||
list.move(boardId, this._id);
|
||||
});
|
||||
|
||||
Swimlanes.update(this._id, {
|
||||
$set: mutatedFields,
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
restore() {
|
||||
if (this.isTemplateSwimlane()) {
|
||||
this.myLists().forEach(list => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue