From f51b33dd87c6444ea9cc07ef62c22c3cac3c55be Mon Sep 17 00:00:00 2001 From: Leo Palmer Sunmo Date: Tue, 5 Oct 2021 12:08:29 +1300 Subject: [PATCH] Add the ability to import checklists from Trello (#1430) * Add the ability to import checklists from Trello * Fix various lint and import issues --- import/trello/importTrello.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/import/trello/importTrello.ts b/import/trello/importTrello.ts index 60ca4cd97..7157d0f9c 100644 --- a/import/trello/importTrello.ts +++ b/import/trello/importTrello.ts @@ -9,6 +9,7 @@ import {IPropertyOption, IPropertyTemplate, createBoard} from '../../webapp/src/ import {createBoardView} from '../../webapp/src/blocks/boardView' import {createCard} from '../../webapp/src/blocks/card' import {createTextBlock} from '../../webapp/src/blocks/textBlock' +import {createCheckboxBlock} from '../../webapp/src/blocks/checkboxBlock' import {Trello} from './trello' import {Utils} from './utils' @@ -135,6 +136,29 @@ function convert(input: Trello): Block[] { outCard.fields.contentOrder = [text.id] } + + // Add Checklists + if (card.idChecklists && card.idChecklists.length > 0) { + card.idChecklists.forEach(checklistID => { + const lookup = input.checklists.find(e => e.id === checklistID) + if (lookup) { + lookup.checkItems.forEach(trelloCheckBox=> { + const checkBlock = createCheckboxBlock() + checkBlock.title = trelloCheckBox.name + if (trelloCheckBox.state === 'complete') { + checkBlock.fields.value = true + } else { + checkBlock.fields.value = false + } + checkBlock.rootId = outCard.rootId + checkBlock.parentId = outCard.id + blocks.push(checkBlock) + + outCard.fields.contentOrder.push(checkBlock.id) + }) + } + }) + } }) console.log('')