mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 15:30:13 +01:00
Fix missing custom fields when cloning board
This commit is contained in:
parent
e8722b56e3
commit
7a08f42edb
1 changed files with 53 additions and 0 deletions
|
|
@ -15,6 +15,7 @@ export class WekanCreator {
|
||||||
cards: {},
|
cards: {},
|
||||||
lists: {},
|
lists: {},
|
||||||
swimlanes: {},
|
swimlanes: {},
|
||||||
|
customFields: {},
|
||||||
};
|
};
|
||||||
// The object creator Wekan Id, indexed by the object Wekan id
|
// The object creator Wekan Id, indexed by the object Wekan id
|
||||||
// (so we only parse actions once!)
|
// (so we only parse actions once!)
|
||||||
|
|
@ -30,6 +31,8 @@ export class WekanCreator {
|
||||||
this.lists = {};
|
this.lists = {};
|
||||||
// Map of cards Wekan ID => Wekan ID
|
// Map of cards Wekan ID => Wekan ID
|
||||||
this.cards = {};
|
this.cards = {};
|
||||||
|
// Map of custom fields Wekan ID => Wekan ID
|
||||||
|
this.customFields = {};
|
||||||
// Map of comments Wekan ID => Wekan ID
|
// Map of comments Wekan ID => Wekan ID
|
||||||
this.commentIds = {};
|
this.commentIds = {};
|
||||||
// Map of attachments Wekan ID => Wekan ID
|
// Map of attachments Wekan ID => Wekan ID
|
||||||
|
|
@ -356,6 +359,17 @@ export class WekanCreator {
|
||||||
if (card.color) {
|
if (card.color) {
|
||||||
cardToCreate.color = card.color;
|
cardToCreate.color = card.color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add custom fields
|
||||||
|
if (card.customFields) {
|
||||||
|
cardToCreate.customFields = card.customFields.map(field => {
|
||||||
|
return {
|
||||||
|
_id: this.customFields[field._id],
|
||||||
|
value: field.value,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// insert card
|
// insert card
|
||||||
const cardId = Cards.direct.insert(cardToCreate);
|
const cardId = Cards.direct.insert(cardToCreate);
|
||||||
// keep track of Wekan id => Wekan id
|
// keep track of Wekan id => Wekan id
|
||||||
|
|
@ -481,6 +495,39 @@ export class WekanCreator {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the Wekan custom fields corresponding to the supplied Wekan
|
||||||
|
* custom fields.
|
||||||
|
* @param wekanCustomFields
|
||||||
|
* @param boardId
|
||||||
|
*/
|
||||||
|
createCustomFields(wekanCustomFields, boardId) {
|
||||||
|
wekanCustomFields.forEach((field, fieldIndex) => {
|
||||||
|
const fieldToCreate = {
|
||||||
|
boardIds: [boardId],
|
||||||
|
name: field.name,
|
||||||
|
type: field.type,
|
||||||
|
settings: field.settings,
|
||||||
|
showOnCard: field.showOnCard,
|
||||||
|
showLabelOnMiniCard: field.showLabelOnMiniCard,
|
||||||
|
automaticallyOnCard: field.automaticallyOnCard,
|
||||||
|
//use date "now" if now created at date is provided (e.g. for very old boards)
|
||||||
|
createdAt: this._now(this.createdAt.customFields[field._id]),
|
||||||
|
modifiedAt: field.modifiedAt,
|
||||||
|
};
|
||||||
|
//insert copy of custom field
|
||||||
|
const fieldId = CustomFields.direct.insert(fieldToCreate);
|
||||||
|
//set modified date to now
|
||||||
|
CustomFields.direct.update(fieldId, {
|
||||||
|
$set: {
|
||||||
|
modifiedAt: this._now(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
//store mapping of old id to new id
|
||||||
|
this.customFields[field._id] = fieldId;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Create labels if they do not exist and load this.labels.
|
// Create labels if they do not exist and load this.labels.
|
||||||
createLabels(wekanLabels, board) {
|
createLabels(wekanLabels, board) {
|
||||||
wekanLabels.forEach(label => {
|
wekanLabels.forEach(label => {
|
||||||
|
|
@ -690,6 +737,11 @@ export class WekanCreator {
|
||||||
this.createdAt.swimlanes[swimlaneId] = activity.createdAt;
|
this.createdAt.swimlanes[swimlaneId] = activity.createdAt;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'createCustomField': {
|
||||||
|
const customFieldId = activity.customFieldId;
|
||||||
|
this.createdAt.customFields[customFieldId] = activity.createdAt;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -840,6 +892,7 @@ export class WekanCreator {
|
||||||
const boardId = this.createBoardAndLabels(board);
|
const boardId = this.createBoardAndLabels(board);
|
||||||
this.createLists(board.lists, boardId);
|
this.createLists(board.lists, boardId);
|
||||||
this.createSwimlanes(board.swimlanes, boardId);
|
this.createSwimlanes(board.swimlanes, boardId);
|
||||||
|
this.createCustomFields(board.customFields, boardId);
|
||||||
this.createCards(board.cards, boardId);
|
this.createCards(board.cards, boardId);
|
||||||
this.createChecklists(board.checklists);
|
this.createChecklists(board.checklists);
|
||||||
this.createChecklistItems(board.checklistItems);
|
this.createChecklistItems(board.checklistItems);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue