Skip to content

Commit

Permalink
fix nextcloud import
Browse files Browse the repository at this point in the history
  • Loading branch information
wiggin77 committed Apr 1, 2022
1 parent d8e9566 commit eb5ed3a
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions import/nextcloud-deck/importDeck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import * as fs from 'fs'
import minimist from 'minimist'
import {exit} from 'process'
import {ArchiveUtils} from '../../webapp/src/blocks/archive'
import {ArchiveUtils} from '../util/archive'
import {Block} from '../../webapp/src/blocks/block'
import {Board as FBBoard} from '../../webapp/src/blocks/board'
import {IPropertyOption, IPropertyTemplate, createBoard} from '../../webapp/src/blocks/board'
import {createBoardView} from '../../webapp/src/blocks/boardView'
import {createCard} from '../../webapp/src/blocks/card'
Expand Down Expand Up @@ -69,10 +70,10 @@ async function main() {
}))

// Convert
const blocks = convert(board, stacks)
const [boards, blocks] = convert(board, stacks)

// // Save output
const outputData = ArchiveUtils.buildBlockArchive(blocks)
const outputData = ArchiveUtils.buildBlockArchive(boards, blocks)
fs.writeFileSync(outputFile, outputData)

console.log(`Exported to ${outputFile}`)
Expand All @@ -85,13 +86,13 @@ async function selectBoard(deckClient: NextcloudDeckClient): Promise<number> {
return readline.questionInt("Enter Board ID: ")
}

function convert(deckBoard: Board, stacks: Stack[]): Block[] {
function convert(deckBoard: Board, stacks: Stack[]): [FBBoard[], Block[]] {
const boards: FBBoard[] = []
const blocks: Block[] = []

// Board
const board = createBoard()
console.log(`Board: ${deckBoard.title}`)
board.rootId = board.id
board.title = deckBoard.title

let colorIndex = 0
Expand Down Expand Up @@ -145,14 +146,14 @@ function convert(deckBoard: Board, stacks: Stack[]): Block[] {
options: []
}

board.fields.cardProperties = [stackProperty, labelProperty, dueDateProperty]
blocks.push(board)
board.cardProperties = [stackProperty, labelProperty, dueDateProperty]
boards.push(board)

// Board view
const view = createBoardView()
view.title = 'Board View'
view.fields.viewType = 'board'
view.rootId = board.id
view.boardId = board.id
view.parentId = board.id
blocks.push(view)

Expand All @@ -164,7 +165,7 @@ function convert(deckBoard: Board, stacks: Stack[]): Block[] {

const outCard = createCard()
outCard.title = card.title
outCard.rootId = board.id
outCard.boardId = board.id
outCard.parentId = board.id

// Map Stacks to Select property options
Expand All @@ -189,7 +190,7 @@ function convert(deckBoard: Board, stacks: Stack[]): Block[] {
if (card.description) {
const text = createTextBlock()
text.title = card.description
text.rootId = board.id
text.boardId = board.id
text.parentId = outCard.id
blocks.push(text)

Expand All @@ -200,7 +201,7 @@ function convert(deckBoard: Board, stacks: Stack[]): Block[] {
card.comments?.forEach(comment => {
const commentBlock = createCommentBlock()
commentBlock.title = comment.message
commentBlock.rootId = board.id
commentBlock.boardId = board.id
commentBlock.parentId = outCard.id
blocks.push(commentBlock)
})
Expand All @@ -210,7 +211,7 @@ function convert(deckBoard: Board, stacks: Stack[]): Block[] {
console.log('')
console.log(`Transformed Board ${deckBoard.title} into ${blocks.length} blocks.`)

return blocks
return [boards, blocks]
}

function showHelp() {
Expand Down

0 comments on commit eb5ed3a

Please sign in to comment.