summaryrefslogtreecommitdiffstats
path: root/models/wekanCreator.js
diff options
context:
space:
mode:
authorAndrés Manelli <andresmanelli@gmail.com>2018-02-02 23:04:54 -0300
committerAndrés Manelli <andresmanelli@gmail.com>2018-02-02 23:04:54 -0300
commitec0a8449ba98aea708e484d386e5a209e2be8fff (patch)
treed44653fe760baabd6cf7e2b728f7f34f4fda2400 /models/wekanCreator.js
parent9df3e3d26bffb2268cdcc7fa768eda60e4f0975c (diff)
downloadwekan-ec0a8449ba98aea708e484d386e5a209e2be8fff.tar.gz
wekan-ec0a8449ba98aea708e484d386e5a209e2be8fff.tar.bz2
wekan-ec0a8449ba98aea708e484d386e5a209e2be8fff.zip
Fix import wekan board with swimlanes
Diffstat (limited to 'models/wekanCreator.js')
-rw-r--r--models/wekanCreator.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/models/wekanCreator.js b/models/wekanCreator.js
index b1533baa..d774db67 100644
--- a/models/wekanCreator.js
+++ b/models/wekanCreator.js
@@ -14,6 +14,7 @@ export class WekanCreator {
board: null,
cards: {},
lists: {},
+ swimlanes: {},
};
// The object creator Wekan Id, indexed by the object Wekan id
// (so we only parse actions once!)
@@ -23,6 +24,8 @@ export class WekanCreator {
// Map of labels Wekan ID => Wekan ID
this.labels = {};
+ // Map of swimlanes Wekan ID => Wekan ID
+ this.swimlanes = {};
// Map of lists Wekan ID => Wekan ID
this.lists = {};
// Map of cards Wekan ID => Wekan ID
@@ -121,6 +124,13 @@ export class WekanCreator {
})]);
}
+ checkSwimlanes(wekanSwimlanes) {
+ check(wekanSwimlanes, [Match.ObjectIncluding({
+ archived: Boolean,
+ title: String,
+ })]);
+ }
+
checkChecklists(wekanChecklists) {
check(wekanChecklists, [Match.ObjectIncluding({
cardId: String,
@@ -213,6 +223,7 @@ export class WekanCreator {
dateLastActivity: this._now(),
description: card.description,
listId: this.lists[card.listId],
+ swimlaneId: this.swimlanes[card.swimlaneId],
sort: card.sort,
title: card.title,
// we attribute the card to its creator if available
@@ -402,6 +413,24 @@ export class WekanCreator {
});
}
+ createSwimlanes(wekanSwimlanes, boardId) {
+ wekanSwimlanes.forEach((swimlane) => {
+ const swimlaneToCreate = {
+ archived: swimlane.archived,
+ boardId,
+ // We are being defensing here by providing a default date (now) if the
+ // creation date wasn't found on the action log. This happen on old
+ // Wekan boards (eg from 2013) that didn't log the 'createList' action
+ // we require.
+ createdAt: this._now(this.createdAt.swimlanes[swimlane._id]),
+ title: swimlane.title,
+ };
+ const swimlaneId = Swimlanes.direct.insert(swimlaneToCreate);
+ Swimlanes.direct.update(swimlaneId, {$set: {'updatedAt': this._now()}});
+ this.swimlanes[swimlane._id] = swimlaneId;
+ });
+ }
+
createChecklists(wekanChecklists) {
wekanChecklists.forEach((checklist, checklistIndex) => {
// Create the checklist
@@ -474,6 +503,11 @@ export class WekanCreator {
const listId = activity.listId;
this.createdAt.lists[listId] = activity.createdAt;
break;
+ }
+ case 'createSwimlane': {
+ const swimlaneId = activity.swimlaneId;
+ this.createdAt.swimlanes[swimlaneId] = activity.createdAt;
+ break;
}}
});
}
@@ -595,6 +629,7 @@ export class WekanCreator {
this.checkBoard(board);
this.checkLabels(board.labels);
this.checkLists(board.lists);
+ this.checkSwimlanes(board.swimlanes);
this.checkCards(board.cards);
this.checkChecklists(board.checklists);
} catch (e) {
@@ -613,6 +648,7 @@ export class WekanCreator {
this.parseActivities(board);
const boardId = this.createBoardAndLabels(board);
this.createLists(board.lists, boardId);
+ this.createSwimlanes(board.swimlanes, boardId);
this.createCards(board.cards, boardId);
this.createChecklists(board.checklists);
this.importActivities(board.activities, boardId);