copied the dashboard and made a keybinding to change back and forth between them; ready to turn dashboard2 into a boardview dashboard

This commit is contained in:
viljarb
2026-03-02 19:53:42 +01:00
parent cb10aeff6b
commit 1d5b7e0860
13 changed files with 1651 additions and 17 deletions

View File

@@ -32,6 +32,7 @@ func (h HelpBar) View() string {
func (h HelpBar) shortHelp() string {
keys := []string{
styles.HighlightKey("tab") + " switch",
styles.HighlightKey("ctrl+2") + " dash2",
styles.HighlightKey("↑/k") + " up",
styles.HighlightKey("↓/j") + " down",
styles.HighlightKey("pgup/pgdn") + " page",
@@ -74,10 +75,11 @@ func (h HelpBar) fullHelp() string {
renderRow("enter", "view issue", "↓/j", "down"),
renderRow("pgup", "page up", "pgdn", "page down"),
renderRow("b", "back to list", "a", "add issue"),
renderRow("e", "edit title", "d", "edit desc"),
renderRow("e", "edit title", "d", "edit description"),
renderRow("s", "change status", "p", "change priority"),
renderRow("t", "change type", "x", "delete issue"),
renderRow("?", "help", "q", "quit"),
renderRow("ctrl+2", "dashboard 2", "q", "quit"),
renderRow("?", "help", "", ""),
}
content := lipgloss.JoinVertical(lipgloss.Left, rows...)
return lipgloss.NewStyle().

View File

@@ -1,25 +1,27 @@
package dashboard
import (
"github.com/LazyBachelor/LazyPM/pkg/tui/msgs"
"github.com/charmbracelet/bubbles/key"
tea "github.com/charmbracelet/bubbletea"
)
type DashboardKeyMap struct {
Help key.Binding
Quit key.Binding
SelectIssue key.Binding
BackToList key.Binding
ScrollUp key.Binding
ScrollDown key.Binding
SwitchWindow key.Binding
EditTitle key.Binding
EditDescription key.Binding
ChangeStatus key.Binding
ChangePriority key.Binding
ChangeType key.Binding
AddIssue key.Binding
DeleteIssue key.Binding
Help key.Binding
Quit key.Binding
SelectIssue key.Binding
BackToList key.Binding
ScrollUp key.Binding
ScrollDown key.Binding
SwitchWindow key.Binding
SwitchToDashboard2 key.Binding
EditTitle key.Binding
EditDescription key.Binding
ChangeStatus key.Binding
ChangePriority key.Binding
ChangeType key.Binding
AddIssue key.Binding
DeleteIssue key.Binding
}
var defaultDashboardKeyMap = DashboardKeyMap{
@@ -51,6 +53,10 @@ var defaultDashboardKeyMap = DashboardKeyMap{
key.WithKeys("tab"),
key.WithHelp("tab", "switch window"),
),
SwitchToDashboard2: key.NewBinding(
key.WithKeys("2"),
key.WithHelp("2", "dashboard 2"),
),
EditTitle: key.NewBinding(
key.WithKeys("e"),
key.WithHelp("e", "edit title"),
@@ -91,6 +97,8 @@ func (d *Model) handleKeyMsg(msg tea.KeyMsg) tea.Cmd {
return tea.Quit
case key.Matches(msg, d.keyMap.SwitchWindow):
d.ToggleFocusedWindow()
case !d.editingTitle && !d.creatingIssue && !d.editingDescription && !d.choosingStatus && !d.choosingPriority && !d.confirmingDelete && !d.choosingType && key.Matches(msg, d.keyMap.SwitchToDashboard2):
return func() tea.Msg { return msgs.SwitchToDashboard2Msg{} }
case d.IsFocusedOnList() && key.Matches(msg, d.keyMap.SelectIssue):
d.FocusDetail()
case d.IsFocusedOnDetail() && key.Matches(msg, d.keyMap.BackToList):