diff options
| author | T <t@tjp.lol> | 2026-02-19 22:24:55 -0700 |
|---|---|---|
| committer | T <t@tjp.lol> | 2026-02-19 22:25:26 -0700 |
| commit | b53c952fc8a054d935d90db2ccf3f0b897e6c771 (patch) | |
| tree | bd67d2281c33f48bb2e3c5f743f14153a2dc148c /internal/tui/app.go | |
| parent | 2ad5e85c729b4a32c4c49584e076ac9f6ce6fa60 (diff) | |
contractor bar across the top
Diffstat (limited to 'internal/tui/app.go')
| -rw-r--r-- | internal/tui/app.go | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/internal/tui/app.go b/internal/tui/app.go index 9850595..05ed358 100644 --- a/internal/tui/app.go +++ b/internal/tui/app.go @@ -16,13 +16,16 @@ import ( type BoxType int const ( - TimerBox BoxType = iota + ContractorBox BoxType = iota + TimerBox ProjectsBox HistoryBox ) func (b BoxType) String() string { switch b { + case ContractorBox: + return "Contractor" case TimerBox: return "Timer" case ProjectsBox: @@ -36,20 +39,24 @@ func (b BoxType) String() string { func (b BoxType) Next() BoxType { switch b { + case ContractorBox: + return TimerBox case TimerBox: return ProjectsBox case ProjectsBox: return HistoryBox case HistoryBox: - return TimerBox + return ContractorBox } return 0 } func (b BoxType) Prev() BoxType { switch b { - case TimerBox: + case ContractorBox: return HistoryBox + case TimerBox: + return ContractorBox case HistoryBox: return ProjectsBox case ProjectsBox: @@ -272,14 +279,12 @@ func (m AppModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } func (m *AppModel) filterHistoryByProjectBox() { - selectedClient := m.projectsBox.clients[m.projectsBox.selectedClient] - m.historyBox.filter.ClientID = &selectedClient.ID - if m.projectsBox.selectedProject != nil { - project := m.projectsBox.projects[selectedClient.ID][*m.projectsBox.selectedProject] - m.historyBox.filter.ProjectID = &project.ID - } else { - m.historyBox.filter.ProjectID = nil + clientID, projectID := m.projectsBox.getSelectedIDs() + if clientID == 0 { + return } + m.historyBox.filter.ClientID = &clientID + m.historyBox.filter.ProjectID = projectID m.historyBox.resetSelection() } @@ -365,12 +370,20 @@ func (m *AppModel) openContractorEditor() { } func (m *AppModel) openClientOrProjectEditor() { - client := m.projectsBox.clients[m.projectsBox.selectedClient] + visibleClients := m.projectsBox.visibleClients() + if m.projectsBox.selectedClient >= len(visibleClients) { + return + } + client := visibleClients[m.projectsBox.selectedClient] if m.projectsBox.selectedProject == nil { m.modalBox.activate(ModalTypeClient, client.ID, *m) m.modalBox.populateClientFields(client) } else { - project := m.projectsBox.projects[client.ID][*m.projectsBox.selectedProject] + visibleProjects := m.projectsBox.visibleProjects(client.ID) + if *m.projectsBox.selectedProject >= len(visibleProjects) { + return + } + project := visibleProjects[*m.projectsBox.selectedProject] m.modalBox.activate(ModalTypeProjectEdit, project.ID, *m) m.modalBox.populateProjectFields(project) } @@ -467,7 +480,13 @@ func (m AppModel) View() string { topBarHeight := 1 bottomBarHeight := 2 - contentHeight := m.height - topBarHeight - bottomBarHeight + + // Render the contractor info panel (full width, matching the main content row). + contractorPanel := RenderContractorPanel(m.contractor, contentWidth, m.selectedBox == ContractorBox) + contractorPanelHeight := lipgloss.Height(contractorPanel) + + // +1 for the newline separator between contractor panel and main content + contentHeight := m.height - topBarHeight - bottomBarHeight - contractorPanelHeight - 1 // Sidebar: fixed comfortable width, capped to avoid dominating sidebarWidth := 38 @@ -506,7 +525,7 @@ func (m AppModel) View() string { keyBindings := activeBindings(m.selectedBox, m.historyBox.viewLevel, m.modalBox) bottomBar := RenderBottomBar(m, keyBindings, m.err, contentWidth) - fullView := topBar + "\n" + mainContent + "\n" + bottomBar + fullView := topBar + "\n" + contractorPanel + "\n" + mainContent + "\n" + bottomBar // Apply modal overlay (uses contentWidth for centering within the content area) fullView = m.modalBox.RenderCenteredOver(fullView, m, contentWidth) |
