Merge remote-tracking branch 'origin/main' into LPM-32
This commit is contained in:
@@ -4,23 +4,28 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/LazyBachelor/LazyPM/internal/service"
|
||||
"github.com/charmbracelet/bubbles/textinput"
|
||||
"github.com/LazyBachelor/LazyPM/pkg/task"
|
||||
"github.com/charmbracelet/bubbles/textarea"
|
||||
"github.com/charmbracelet/bubbles/textinput"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
)
|
||||
|
||||
type ValidationFeedbackMsg struct {
|
||||
Feedback task.ValidationFeedback
|
||||
}
|
||||
|
||||
type Model struct {
|
||||
header Header
|
||||
issueList IssueList
|
||||
issueDetail IssueDetail
|
||||
header Header
|
||||
issueList IssueList
|
||||
issueDetail IssueDetail
|
||||
closedIssueList IssueList
|
||||
helpBar HelpBar
|
||||
keyMap DashboardKeyMap
|
||||
svc *service.Services
|
||||
width int
|
||||
height int
|
||||
helpBar HelpBar
|
||||
keyMap DashboardKeyMap
|
||||
svc *service.Services
|
||||
width int
|
||||
height int
|
||||
focusedWindow int // 0 = main (display issues), 1 = closed issues
|
||||
focusedPaneMain int // 0 = list, 1 = detail
|
||||
focusedPaneMain int // 0 = list, 1 = detail
|
||||
focusedPaneClosed int
|
||||
|
||||
editingTitle bool // true while we are editing a title
|
||||
@@ -39,18 +44,24 @@ type Model struct {
|
||||
|
||||
choosingStatus bool
|
||||
statusIssueID string
|
||||
feedbackChan chan task.ValidationFeedback
|
||||
quitChan chan bool
|
||||
currentFeedback task.ValidationFeedback
|
||||
showComplete bool
|
||||
}
|
||||
|
||||
func NewDashboard(svc *service.Services) *Model {
|
||||
func NewDashboard(svc *service.Services, feedbackChan chan task.ValidationFeedback, quitChan chan bool) *Model {
|
||||
m := &Model{
|
||||
header: NewHeader("Project Manager Dashboard"),
|
||||
keyMap: defaultDashboardKeyMap,
|
||||
svc: svc,
|
||||
width: 80,
|
||||
height: 24,
|
||||
header: NewHeader("Project Manager Dashboard"),
|
||||
keyMap: defaultDashboardKeyMap,
|
||||
svc: svc,
|
||||
width: 80,
|
||||
height: 24,
|
||||
focusedWindow: 0,
|
||||
focusedPaneMain: 0,
|
||||
focusedPaneClosed: 0,
|
||||
focusedPaneClosed: 0,
|
||||
feedbackChan: feedbackChan,
|
||||
quitChan: quitChan,
|
||||
}
|
||||
|
||||
allIssues, _ := svc.Beads.AllIssues(context.Background())
|
||||
@@ -116,7 +127,14 @@ func (m *Model) startChooseStatus(selected ListIssue) {
|
||||
}
|
||||
|
||||
func (m *Model) Init() tea.Cmd {
|
||||
return nil
|
||||
return m.listenForValidation()
|
||||
}
|
||||
|
||||
func (m *Model) listenForValidation() tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
feedback := <-m.feedbackChan
|
||||
return ValidationFeedbackMsg{Feedback: feedback}
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Model) IsFocusedOnList() bool {
|
||||
|
||||
@@ -15,10 +15,10 @@ func (m *Model) View() string {
|
||||
header := m.header.View(m.width)
|
||||
headerHeight := m.header.Height()
|
||||
|
||||
bottomView := m.helpBar.View()
|
||||
bottomHeight := m.helpBar.Height()
|
||||
footer := m.footer()
|
||||
footerHeight := lipgloss.Height(footer)
|
||||
|
||||
contentHeight := m.height - headerHeight - bottomHeight
|
||||
contentHeight := m.height - headerHeight - footerHeight
|
||||
halfHeight := contentHeight / 2
|
||||
if halfHeight < 1 {
|
||||
halfHeight = 1
|
||||
@@ -49,7 +49,7 @@ func (m *Model) View() string {
|
||||
)
|
||||
content := lipgloss.JoinHorizontal(lipgloss.Left, leftColumn, detailView)
|
||||
|
||||
mainView := lipgloss.JoinVertical(lipgloss.Left, header, content, bottomView)
|
||||
mainView := lipgloss.JoinVertical(lipgloss.Left, header, content, footer)
|
||||
|
||||
if m.editingTitle {
|
||||
editBoxWidth := min(60, m.width-4)
|
||||
@@ -122,4 +122,16 @@ func (m *Model) View() string {
|
||||
}
|
||||
|
||||
return mainView
|
||||
|
||||
}
|
||||
|
||||
func (m *Model) footer() string {
|
||||
feedbackStatus := m.currentFeedback.Message
|
||||
|
||||
if feedbackStatus == "" {
|
||||
return m.helpBar.View()
|
||||
}
|
||||
|
||||
m.helpBar.SetWidth(m.width - lipgloss.Width(feedbackStatus))
|
||||
return lipgloss.JoinHorizontal(lipgloss.Left, m.helpBar.View(), feedbackStatus)
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@ package views
|
||||
|
||||
import (
|
||||
"github.com/LazyBachelor/LazyPM/internal/service"
|
||||
"github.com/LazyBachelor/LazyPM/pkg/task"
|
||||
"github.com/LazyBachelor/LazyPM/pkg/tui/views/dashboard"
|
||||
)
|
||||
|
||||
func NewDashboardView(svc *service.Services) *dashboard.Model {
|
||||
return dashboard.NewDashboard(svc)
|
||||
func NewDashboardView(svc *service.Services, feedbackChan chan task.ValidationFeedback, quitChan chan bool) *dashboard.Model {
|
||||
return dashboard.NewDashboard(svc, feedbackChan, quitChan)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user