Skip to content

Commit

Permalink
add create default stacks on new board action feature
Browse files Browse the repository at this point in the history
  • Loading branch information
mebitek committed Jun 9, 2023
1 parent f88b705 commit a5135b6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
18 changes: 16 additions & 2 deletions deck_board/deck_board.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,16 @@ func addBoard(board deck_structs.Board) {
}
Boards = append(Boards, newBoard)
BoardList.AddItem(fmt.Sprintf("[#%s]#%d - %s", newBoard.Color, newBoard.Id, newBoard.Title), "", rune(0), nil)
if board.CreateDefaults {
var items []string = []string{"Todo", "Running", "Complete"}
for i, s := range items {
stack := deck_structs.Stack{
Title: s,
Order: i,
}
_ = deck_stack.AddStack(newBoard.Id, stack)
}
}

deck_ui.BuildFullFlex(BoardFlex, err)
}
Expand Down Expand Up @@ -357,11 +367,11 @@ func buildAddLabelForm(l deck_structs.Label) (*tview.Form, *deck_structs.Label)

func buildAddBoardForm(b deck_structs.Board) (*tview.Form, *deck_structs.Board) {
addForm := tview.NewForm()
var board deck_structs.Board = deck_structs.Board{}
var board = deck_structs.Board{}
var title = " Add Board "
if b.Id != 0 {
board = b
title = " Edit Boasrd "
title = " Edit Boaard "
}
addForm.SetTitle(title)
addForm.SetBorder(true)
Expand All @@ -384,5 +394,9 @@ func buildAddBoardForm(b deck_structs.Board) (*tview.Form, *deck_structs.Board)
board.Color = color
})

addForm.AddCheckbox("Create default stacks", false, func(checked bool) {
board.CreateDefaults = checked
})

return addForm, &board
}
2 changes: 1 addition & 1 deletion deck_card/deck_card.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ func BuildStacks() {

for index, s := range deck_stack.Stacks {
todoList := tview.NewList()
todoList.SetTitle(fmt.Sprintf("%s ", s.Title))
todoList.SetTitle(fmt.Sprintf(" %s ", s.Title))
todoList.SetBorder(true)

todoList.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
Expand Down
17 changes: 9 additions & 8 deletions deck_structs/deck_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ type Owner struct {
}

type Board struct {
Id int `json:"id"`
Title string `json:"title"`
Owner Owner `json:"owner"`
Color string `json:"color"`
Labels []Label `json:"labels"`
Etag string `json:"etag"`
Updated bool `json:"-"`
DeletedAt int `json:"deletedAt"`
Id int `json:"id"`
Title string `json:"title"`
Owner Owner `json:"owner"`
Color string `json:"color"`
Labels []Label `json:"labels"`
Etag string `json:"etag"`
Updated bool `json:"-"`
CreateDefaults bool `json:"-"`
DeletedAt int `json:"deletedAt"`
}

type Stack struct {
Expand Down
2 changes: 1 addition & 1 deletion deck_ui/deck_ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"tui-deck/utils"
)

const VERSION = "v0.5.8"
const VERSION = "v0.5.9"

var FullFlex = tview.NewFlex()
var MainFlex = tview.NewFlex()
Expand Down

0 comments on commit a5135b6

Please sign in to comment.