1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-12-24 13:43:12 +02:00

fix todolist import

This commit is contained in:
wiggin77 2022-03-31 22:50:58 -04:00
parent aa3837814b
commit 400c5a108c

View File

@ -5,6 +5,7 @@ import minimist from 'minimist'
import {exit} from 'process' import {exit} from 'process'
import {ArchiveUtils} from '../util/archive' import {ArchiveUtils} from '../util/archive'
import {Block} from '../../webapp/src/blocks/block' import {Block} from '../../webapp/src/blocks/block'
import {Board} from '../../webapp/src/blocks/board'
import {IPropertyOption, IPropertyTemplate, createBoard} from '../../webapp/src/blocks/board' import {IPropertyOption, IPropertyTemplate, createBoard} from '../../webapp/src/blocks/board'
import {createBoardView} from '../../webapp/src/blocks/boardView' import {createBoardView} from '../../webapp/src/blocks/boardView'
import {createCard} from '../../webapp/src/blocks/card' import {createCard} from '../../webapp/src/blocks/card'
@ -56,31 +57,34 @@ function main() {
const inputData = fs.readFileSync(inputFile, 'utf-8') const inputData = fs.readFileSync(inputFile, 'utf-8')
const input = JSON.parse(inputData) as Todoist const input = JSON.parse(inputData) as Todoist
const boards = [] as Board[]
const blocks = [] as Block[] const blocks = [] as Block[]
input.projects.forEach(project => { input.projects.forEach(project => {
blocks.push(...convert(input, project)) const [brds, blks] = convert(input, project)
boards.push(...brds)
blocks.push(...blks)
}) })
// Save output // Save output
// TODO: Stream output // TODO: Stream output
const outputData = ArchiveUtils.buildBlockArchive(blocks) const outputData = ArchiveUtils.buildBlockArchive(boards, blocks)
fs.writeFileSync(outputFile, outputData) fs.writeFileSync(outputFile, outputData)
console.log(`Exported to ${outputFile}`) console.log(`Exported to ${outputFile}`)
} }
function convert(input: Todoist, project: Project): Block[] { function convert(input: Todoist, project: Project): [Board[], Block[]] {
const boards: Board[] = []
const blocks: Block[] = [] const blocks: Block[] = []
if (project.name === 'Inbox') { if (project.name === 'Inbox') {
return blocks return [boards, blocks]
} }
// Board // Board
const board = createBoard() const board = createBoard()
console.log(`Board: ${project.name}`) console.log(`Board: ${project.name}`)
board.rootId = board.id
board.title = project.name board.title = project.name
board.description = project.name board.description = project.name
@ -115,13 +119,13 @@ function convert(input: Todoist, project: Project): Block[] {
options options
} }
board.cardProperties = [cardProperty] board.cardProperties = [cardProperty]
blocks.push(board) boards.push(board)
// Board view // Board view
const view = createBoardView() const view = createBoardView()
view.title = 'Board View' view.title = 'Board View'
view.fields.viewType = 'board' view.fields.viewType = 'board'
view.rootId = board.id view.boardId = board.id
view.parentId = board.id view.parentId = board.id
blocks.push(view) blocks.push(view)
@ -130,7 +134,7 @@ function convert(input: Todoist, project: Project): Block[] {
cards.forEach(card => { cards.forEach(card => {
const outCard = createCard() const outCard = createCard()
outCard.title = card.content outCard.title = card.content
outCard.rootId = board.id outCard.boardId = board.id
outCard.parentId = board.id outCard.parentId = board.id
// Map lists to Select property options // Map lists to Select property options
@ -148,14 +152,14 @@ function convert(input: Todoist, project: Project): Block[] {
// console.log(`\t${card.desc}`) // console.log(`\t${card.desc}`)
const text = createTextBlock() const text = createTextBlock()
text.title = getCardDescription(input, card).join('\n\n') text.title = getCardDescription(input, card).join('\n\n')
text.rootId = board.id text.boardId = board.id
text.parentId = outCard.id text.parentId = outCard.id
blocks.push(text) blocks.push(text)
outCard.fields.contentOrder = [text.id] outCard.fields.contentOrder = [text.id]
}) })
return blocks return [boards, blocks]
} }
function getProjectColumns(input: Todoist, project: Project): Array<Section> { function getProjectColumns(input: Todoist, project: Project): Array<Section> {