mirror of
https://github.com/wekan/wekan.git
synced 2025-09-22 01:50:48 +02: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
|
@ -346,9 +346,6 @@ BlazeComponent.extendComponent({
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log('boards.count():', boards.count());
|
|
||||||
console.log('boards:', boards);
|
|
||||||
|
|
||||||
return boards;
|
return boards;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -361,8 +358,7 @@ BlazeComponent.extendComponent({
|
||||||
let boardId;
|
let boardId;
|
||||||
if (bSelect) {
|
if (bSelect) {
|
||||||
boardId = bSelect.options[bSelect.selectedIndex].value;
|
boardId = bSelect.options[bSelect.selectedIndex].value;
|
||||||
swimlane.move(boardId);
|
Meteor.call('moveSwimlane', this.currentSwimlane._id, boardId);
|
||||||
this.board().getDefaultSwimline();
|
|
||||||
}
|
}
|
||||||
Popup.close();
|
Popup.close();
|
||||||
},
|
},
|
||||||
|
|
|
@ -202,7 +202,7 @@ Lists.helpers({
|
||||||
this.swimlaneId = swimlaneId;
|
this.swimlaneId = swimlaneId;
|
||||||
|
|
||||||
let _id = null;
|
let _id = null;
|
||||||
existingListWithSameName = Lists.findOne({
|
const existingListWithSameName = Lists.findOne({
|
||||||
boardId,
|
boardId,
|
||||||
title: this.title,
|
title: this.title,
|
||||||
archived: false,
|
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) {
|
cards(swimlaneId) {
|
||||||
const selector = {
|
const selector = {
|
||||||
listId: this._id,
|
listId: this._id,
|
||||||
|
@ -297,36 +326,6 @@ Lists.mutations({
|
||||||
return { $set: { starred: !!enable } };
|
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() {
|
archive() {
|
||||||
if (this.isTemplateList()) {
|
if (this.isTemplateList()) {
|
||||||
this.cards().forEach(card => {
|
this.cards().forEach(card => {
|
||||||
|
|
|
@ -269,36 +269,6 @@ Swimlanes.mutations({
|
||||||
return { $set: { archived: true, archivedAt: new Date() } };
|
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 => {
|
|
||||||
const boardList = Lists.findOne({ boardId, title: list.title });
|
|
||||||
|
|
||||||
if (boardList) {
|
|
||||||
list.cards().forEach(card => {
|
|
||||||
card.move(boardId, this._id, boardList._id);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
list.move(boardId, this._id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Swimlanes.update(this._id, {
|
|
||||||
$set: mutatedFields,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
restore() {
|
restore() {
|
||||||
if (this.isTemplateSwimlane()) {
|
if (this.isTemplateSwimlane()) {
|
||||||
this.myLists().forEach(list => {
|
this.myLists().forEach(list => {
|
||||||
|
|
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