mirror of
https://github.com/wekan/wekan.git
synced 2025-12-22 10:20:14 +01:00
Merge pull request #3154 from marc1006/issue_2970
Copy the labels only if the target board is different
This commit is contained in:
commit
39a8524354
1 changed files with 60 additions and 51 deletions
|
|
@ -368,8 +368,15 @@ Cards.allow({
|
|||
|
||||
Cards.helpers({
|
||||
copy(boardId, swimlaneId, listId) {
|
||||
const oldId = this._id;
|
||||
const oldCard = Cards.findOne(oldId);
|
||||
|
||||
// we must only copy the labels and custom fields if the target board
|
||||
// differs from the source board
|
||||
if (this.boardId !== boardId) {
|
||||
const oldBoard = Boards.findOne(this.boardId);
|
||||
const oldBoardLabels = oldBoard.labels;
|
||||
|
||||
// Get old label names
|
||||
const oldCardLabels = _.pluck(
|
||||
_.filter(oldBoardLabels, label => {
|
||||
|
|
@ -386,12 +393,11 @@ Cards.helpers({
|
|||
}),
|
||||
'_id',
|
||||
);
|
||||
|
||||
const oldId = this._id;
|
||||
const oldCard = Cards.findOne(oldId);
|
||||
// now set the new label ids
|
||||
delete this.labelIds;
|
||||
this.labelIds = newCardLabels;
|
||||
|
||||
// Copy Custom Fields
|
||||
if (oldBoard._id !== boardId) {
|
||||
CustomFields.find({
|
||||
_id: {
|
||||
$in: oldCard.customFields.map(cf => {
|
||||
|
|
@ -404,8 +410,6 @@ Cards.helpers({
|
|||
}
|
||||
|
||||
delete this._id;
|
||||
delete this.labelIds;
|
||||
this.labelIds = newCardLabels;
|
||||
this.boardId = boardId;
|
||||
this.swimlaneId = swimlaneId;
|
||||
this.listId = listId;
|
||||
|
|
@ -1298,19 +1302,16 @@ Cards.mutations({
|
|||
},
|
||||
|
||||
move(boardId, swimlaneId, listId, sort) {
|
||||
// Copy Custom Fields
|
||||
if (this.boardId !== boardId) {
|
||||
CustomFields.find({
|
||||
_id: {
|
||||
$in: this.customFields.map(cf => {
|
||||
return cf._id;
|
||||
}),
|
||||
},
|
||||
}).forEach(cf => {
|
||||
if (!_.contains(cf.boardIds, boardId)) cf.addBoard(boardId);
|
||||
});
|
||||
}
|
||||
const mutatedFields = {
|
||||
boardId,
|
||||
swimlaneId,
|
||||
listId,
|
||||
sort,
|
||||
};
|
||||
|
||||
// we must only copy the labels and custom fields if the target board
|
||||
// differs from the source board
|
||||
if (this.boardId !== boardId) {
|
||||
// Get label names
|
||||
const oldBoard = Boards.findOne(this.boardId);
|
||||
const oldBoardLabels = oldBoard.labels;
|
||||
|
|
@ -1330,13 +1331,21 @@ Cards.mutations({
|
|||
'_id',
|
||||
);
|
||||
|
||||
const mutatedFields = {
|
||||
boardId,
|
||||
swimlaneId,
|
||||
listId,
|
||||
sort,
|
||||
Object.assign(mutatedFields, {
|
||||
labelIds: newCardLabelIds,
|
||||
};
|
||||
});
|
||||
|
||||
// Copy custom fields
|
||||
CustomFields.find({
|
||||
_id: {
|
||||
$in: this.customFields.map(cf => {
|
||||
return cf._id;
|
||||
}),
|
||||
},
|
||||
}).forEach(cf => {
|
||||
if (!_.contains(cf.boardIds, boardId)) cf.addBoard(boardId);
|
||||
});
|
||||
}
|
||||
|
||||
Cards.update(this._id, {
|
||||
$set: mutatedFields,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue