Sfoglia il codice sorgente

Fixed Wekan JSON import fails.

Thanks to BartoszBroda and xet7 !

Fixes #3918
Lauri Ojansivu 3 anni fa
parent
commit
0fa8fc8b50
1 ha cambiato i file con 15 aggiunte e 11 eliminazioni
  1. 15 11
      models/wekanCreator.js

+ 15 - 11
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);
     const boardId = Boards.direct.insert(boardToCreate);
     Boards.direct.update(boardId, {
     Boards.direct.update(boardId, {
       $set: {
       $set: {