Add support for converting checklists

This commit is contained in:
kolaente 2020-12-16 23:47:30 +01:00
parent 3221602fdf
commit 0941b7e1dd
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 54 additions and 5 deletions

View File

@ -102,7 +102,7 @@ func getTrelloData(token string) (trelloData []*trello.Board, err error) {
listMap[list.ID] = list
}
cards, err := board.GetCards(trello.Defaults())
cards, err := board.GetCards(trello.Arguments{"fields": "all"})
if err != nil {
return nil, err
}
@ -164,9 +164,19 @@ func convertTrelloDataToVikunja(trelloData []*trello.Board) (fullVikunjaHierachi
}
// Checklists (as markdown in description)
//for _, checklist := range card.Checklists {
//
//}
for _, checklist := range card.Checklists {
task.Description += "\n\n## " + checklist.Name + "\n"
for _, item := range checklist.CheckItems {
task.Description += "\n* "
if item.State == "completed" {
task.Description += "[x]"
} else {
task.Description += "[ ]"
}
task.Description += " " + item.Name
}
}
// Labels
for _, label := range card.Labels {

View File

@ -75,6 +75,34 @@ func TestConvertTrelloToVikunja(t *testing.T) {
{
Name: "Test Card 2",
Pos: 124,
Checklists: []*trello.Checklist{
{
Name: "Checklist 1",
CheckItems: []trello.CheckItem{
{
State: "pending",
Name: "Pending Task",
},
{
State: "completed",
Name: "Completed Task",
},
},
},
{
Name: "Checklist 2",
CheckItems: []trello.CheckItem{
{
State: "pending",
Name: "Pending Task",
},
{
State: "pending",
Name: "Another Pending Task",
},
},
},
},
},
{
Name: "Test Card 3",
@ -205,7 +233,18 @@ func TestConvertTrelloToVikunja(t *testing.T) {
},
},
{
Title: "Test Card 2",
Title: "Test Card 2",
Description: `
## Checklist 1
* [ ] Pending Task
* [x] Completed Task
## Checklist 2
* [ ] Pending Task
* [ ] Another Pending Task`,
BucketID: 1,
Position: 124,
},