mirror of
https://github.com/wekan/wekan.git
synced 2026-02-02 06:31:47 +01:00
Merge branch 'master' of https://github.com/wekan/wekan into new-search
This commit is contained in:
commit
f56caa745a
72 changed files with 245 additions and 133 deletions
|
|
@ -518,6 +518,25 @@ Boards.helpers({
|
|||
swimlane.type = 'swimlane';
|
||||
swimlane.copy(_id);
|
||||
});
|
||||
|
||||
// copy custom field definitions
|
||||
const cfMap = {};
|
||||
CustomFields.find({ boardIds: oldId }).forEach(cf => {
|
||||
const id = cf._id;
|
||||
delete cf._id;
|
||||
cf.boardIds = [_id];
|
||||
cfMap[id] = CustomFields.insert(cf);
|
||||
});
|
||||
Cards.find({ boardId: _id }).forEach(card => {
|
||||
Cards.update(card._id, {
|
||||
$set: {
|
||||
customFields: card.customFields.map(cf => {
|
||||
cf._id = cfMap[cf._id];
|
||||
return cf;
|
||||
}),
|
||||
},
|
||||
});
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Is supplied user authorized to view this board?
|
||||
|
|
|
|||
|
|
@ -367,6 +367,24 @@ Cards.allow({
|
|||
});
|
||||
|
||||
Cards.helpers({
|
||||
mapCustomFieldsToBoard(boardId) {
|
||||
// Map custom fields to new board
|
||||
return this.customFields.map(cf => {
|
||||
const oldCf = CustomFields.findOne(cf._id);
|
||||
const newCf = CustomFields.findOne({
|
||||
boardIds: boardId,
|
||||
name: oldCf.name,
|
||||
type: oldCf.type,
|
||||
});
|
||||
if (newCf) {
|
||||
cf._id = newCf._id;
|
||||
} else if (!_.contains(oldCf.boardIds, boardId)) {
|
||||
oldCf.addBoard(boardId);
|
||||
}
|
||||
return cf;
|
||||
});
|
||||
},
|
||||
|
||||
copy(boardId, swimlaneId, listId) {
|
||||
const oldId = this._id;
|
||||
const oldCard = Cards.findOne(oldId);
|
||||
|
|
@ -397,16 +415,7 @@ Cards.helpers({
|
|||
delete this.labelIds;
|
||||
this.labelIds = newCardLabels;
|
||||
|
||||
// Copy Custom Fields
|
||||
CustomFields.find({
|
||||
_id: {
|
||||
$in: oldCard.customFields.map(cf => {
|
||||
return cf._id;
|
||||
}),
|
||||
},
|
||||
}).forEach(cf => {
|
||||
if (!_.contains(cf.boardIds, boardId)) cf.addBoard(boardId);
|
||||
});
|
||||
this.customFields = this.mapCustomFieldsToBoard(newBoard._id);
|
||||
}
|
||||
|
||||
delete this._id;
|
||||
|
|
@ -1528,16 +1537,7 @@ Cards.mutations({
|
|||
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);
|
||||
});
|
||||
mutatedFields.customFields = this.mapCustomFieldsToBoard(newBoard._id);
|
||||
}
|
||||
|
||||
Cards.update(this._id, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue