From 0fa8fc8b506831a60649d100ce93c96f8f7b76f5 Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Mon, 26 Jul 2021 14:01:09 +0300 Subject: [PATCH] Fixed Wekan JSON import fails. Thanks to BartoszBroda and xet7 ! Fixes #3918 --- models/wekanCreator.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/models/wekanCreator.js b/models/wekanCreator.js index 2867b12f8..310230e7c 100644 --- a/models/wekanCreator.js +++ b/models/wekanCreator.js @@ -271,17 +271,21 @@ export class WekanCreator { }); }); } - boardToImport.labels.forEach(label => { - const labelToCreate = { - _id: Random.id(6), - color: label.color, - name: label.name, - }; - // We need to remember them by Wekan ID, as this is the only ref we have - // when importing cards. - this.labels[label._id] = labelToCreate._id; - boardToCreate.labels.push(labelToCreate); - }); + + if (boardToImport.labels) { + boardToImport.labels.forEach(label => { + const labelToCreate = { + _id: Random.id(6), + color: label.color, + name: label.name, + }; + // We need to remember them by Wekan ID, as this is the only ref we have + // when importing cards. + this.labels[label._id] = labelToCreate._id; + boardToCreate.labels.push(labelToCreate); + }); + } + const boardId = Boards.direct.insert(boardToCreate); Boards.direct.update(boardId, { $set: {