summaryrefslogtreecommitdiffstats
path: root/models/trelloCreator.js
diff options
context:
space:
mode:
authorGhassen Rjab <rjab.ghassen@gmail.com>2017-09-26 06:58:39 +0100
committerGhassen Rjab <rjab.ghassen@gmail.com>2017-09-26 06:58:39 +0100
commitf883757552c839309a8072b6e97da1da3ee38d87 (patch)
tree5f12e0b26ad655126e363d692cc0b8efc7b3339b /models/trelloCreator.js
parenteb945f26a3be316fb2ae4452d6db45a11f8b91d4 (diff)
downloadwekan-f883757552c839309a8072b6e97da1da3ee38d87.tar.gz
wekan-f883757552c839309a8072b6e97da1da3ee38d87.tar.bz2
wekan-f883757552c839309a8072b6e97da1da3ee38d87.zip
Ignore checklists with missing cards
Diffstat (limited to 'models/trelloCreator.js')
-rw-r--r--models/trelloCreator.js42
1 files changed, 22 insertions, 20 deletions
diff --git a/models/trelloCreator.js b/models/trelloCreator.js
index e7f98e85..909128f0 100644
--- a/models/trelloCreator.js
+++ b/models/trelloCreator.js
@@ -398,27 +398,29 @@ export class TrelloCreator {
createChecklists(trelloChecklists) {
trelloChecklists.forEach((checklist) => {
- // Create the checklist
- const checklistToCreate = {
- cardId: this.cards[checklist.idCard],
- title: checklist.name,
- createdAt: this._now(),
- sort: checklist.pos,
- };
- const checklistId = Checklists.direct.insert(checklistToCreate);
- // keep track of Trello id => WeKan id
- this.checklists[checklist.id] = checklistId;
- // Now add the items to the checklist
- const itemsToCreate = [];
- checklist.checkItems.forEach((item) => {
- itemsToCreate.push({
- _id: checklistId + itemsToCreate.length,
- title: item.name,
- isFinished: item.state === 'complete',
- sort: item.pos,
+ if (this.cards[checklist.idCard]) {
+ // Create the checklist
+ const checklistToCreate = {
+ cardId: this.cards[checklist.idCard],
+ title: checklist.name,
+ createdAt: this._now(),
+ sort: checklist.pos,
+ };
+ const checklistId = Checklists.direct.insert(checklistToCreate);
+ // keep track of Trello id => WeKan id
+ this.checklists[checklist.id] = checklistId;
+ // Now add the items to the checklist
+ const itemsToCreate = [];
+ checklist.checkItems.forEach((item) => {
+ itemsToCreate.push({
+ _id: checklistId + itemsToCreate.length,
+ title: item.name,
+ isFinished: item.state === 'complete',
+ sort: item.pos,
+ });
});
- });
- Checklists.direct.update(checklistId, {$set: {items: itemsToCreate}});
+ Checklists.direct.update(checklistId, {$set: {items: itemsToCreate}});
+ }
});
}