Skip to content

Commit

Permalink
Bugfix: Fix active list when switched from any other page to board page
Browse files Browse the repository at this point in the history
  • Loading branch information
singalhimanshu committed Dec 2, 2020
1 parent f5c45f6 commit e53ad9f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions ui/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ func NewAddPage(p *BoardPage) *tview.Form {
p.data.Save()
p.redraw()
pages.SwitchToPage("board")
app.SetFocus(p.lists[p.activeListIdx])
}).
AddButton("Cancel", func() {
pages.RemovePage("add")
pages.SwitchToPage("board")
app.SetFocus(p.lists[p.activeListIdx])
})

form.SetBorder(true).SetTitle("Create Task").SetTitleAlign(tview.AlignCenter)
Expand Down
2 changes: 1 addition & 1 deletion ui/board.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (p *BoardPage) Page() tview.Primitive {
p.data.Save()
app.Stop()
case '?':
pages.SwitchToPage("help")
pages.AddAndSwitchToPage("help", NewHelpPage(p), true)
case ' ':
pages.AddAndSwitchToPage("info", NewInfoPage(p, p.activeListIdx, p.activeTaskIdxs[p.activeListIdx]), true)
default:
Expand Down
2 changes: 2 additions & 0 deletions ui/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ func NewEditPage(p *BoardPage, listIdx, taskIdx int) *tview.Form {
p.data.Save()
p.redraw()
pages.SwitchToPage("board")
app.SetFocus(p.lists[p.activeListIdx])
}).
AddButton("Cancel", func() {
pages.RemovePage("edit")
pages.SwitchToPage("board")
app.SetFocus(p.lists[p.activeListIdx])
})

form.SetBorder(true).SetTitle("Edit Task").SetTitleAlign(tview.AlignCenter)
Expand Down
3 changes: 2 additions & 1 deletion ui/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ q: quit
`

// NewHelpPage displays the help page that contains all the keybinds of the application
func NewHelpPage() *tview.Modal {
func NewHelpPage(p *BoardPage) *tview.Modal {
help := tview.NewModal().
SetText(helpText).
SetBackgroundColor(theme.PrimitiveBackgroundColor).
Expand All @@ -27,6 +27,7 @@ func NewHelpPage() *tview.Modal {
if buttonLabel == "OK" {
pages.HidePage("help")
pages.SwitchToPage("board")
app.SetFocus(p.lists[p.activeListIdx])
}
})

Expand Down
1 change: 1 addition & 0 deletions ui/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func NewInfoPage(p *BoardPage, listIdx, taskIdx int) *tview.Modal {
if buttonLabel == "OK" {
pages.RemovePage("info")
pages.SwitchToPage("board")
app.SetFocus(p.lists[p.activeListIdx])
}
})

Expand Down
6 changes: 1 addition & 5 deletions ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ func start() {
boardPage := NewBoardPage()
boardPageFrame := boardPage.Page()

helpPage := NewHelpPage()

pages = tview.NewPages().
AddPage("board", boardPageFrame, true, true).
AddPage("help", helpPage, false, false)

AddPage("board", boardPageFrame, true, true)
app.SetRoot(pages, true).SetFocus(boardPageFrame)
}

0 comments on commit e53ad9f

Please sign in to comment.