mirror of
https://github.com/wekan/wekan.git
synced 2026-01-21 16:56:11 +01:00
fixed #6011
This commit is contained in:
parent
d27c8e99ed
commit
15172f401d
2 changed files with 359 additions and 1 deletions
|
|
@ -57,6 +57,33 @@ export class WekanCreator {
|
|||
|
||||
// maps a wekanCardId to an array of wekanAttachments
|
||||
this.attachments = {};
|
||||
|
||||
// default swimlane id created during import if necessary
|
||||
this._defaultSwimlaneId = null;
|
||||
|
||||
// Normalize possible exported id fields: some exports may use `id` instead of `_id`.
|
||||
// Ensure every item we rely on has an `_id` so mappings work consistently.
|
||||
const normalizeIds = arr => {
|
||||
if (!arr) return;
|
||||
arr.forEach(item => {
|
||||
if (item && item.id && !item._id) {
|
||||
item._id = item.id;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
normalizeIds(data.lists);
|
||||
normalizeIds(data.cards);
|
||||
normalizeIds(data.swimlanes);
|
||||
normalizeIds(data.checklists);
|
||||
normalizeIds(data.checklistItems);
|
||||
normalizeIds(data.triggers);
|
||||
normalizeIds(data.actions);
|
||||
normalizeIds(data.labels);
|
||||
normalizeIds(data.customFields);
|
||||
normalizeIds(data.comments);
|
||||
normalizeIds(data.activities);
|
||||
normalizeIds(data.rules);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -329,7 +356,7 @@ export class WekanCreator {
|
|||
dateLastActivity: this._now(),
|
||||
description: card.description,
|
||||
listId: this.lists[card.listId],
|
||||
swimlaneId: this.swimlanes[card.swimlaneId],
|
||||
swimlaneId: this.swimlanes[card.swimlaneId] || this._defaultSwimlaneId,
|
||||
sort: card.sort,
|
||||
title: card.title,
|
||||
// we attribute the card to its creator if available
|
||||
|
|
@ -915,6 +942,24 @@ export class WekanCreator {
|
|||
const boardId = this.createBoardAndLabels(board);
|
||||
this.createLists(board.lists, boardId);
|
||||
this.createSwimlanes(board.swimlanes, boardId);
|
||||
// If no swimlanes were provided in the exported data, create a default
|
||||
// swimlane so that cards referencing no swimlane still appear on the board.
|
||||
if (!this.swimlanes || Object.keys(this.swimlanes).length === 0) {
|
||||
const swimlaneToCreate = {
|
||||
archived: false,
|
||||
boardId,
|
||||
createdAt: this._now(),
|
||||
title: 'Default',
|
||||
sort: 0,
|
||||
};
|
||||
const created = Swimlanes.direct.insert(swimlaneToCreate);
|
||||
Swimlanes.direct.update(created, { $set: { updatedAt: this._now() } });
|
||||
this._defaultSwimlaneId = created;
|
||||
} else {
|
||||
// pick first existing swimlane as default fallback
|
||||
const existing = Object.values(this.swimlanes)[0];
|
||||
this._defaultSwimlaneId = existing || null;
|
||||
}
|
||||
this.createCustomFields(board.customFields, boardId);
|
||||
this.createCards(board.cards, boardId);
|
||||
this.createSubtasks(board.cards);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue