summaryrefslogtreecommitdiff
path: root/internal/tui/app.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/tui/app.go')
-rw-r--r--internal/tui/app.go44
1 files changed, 42 insertions, 2 deletions
diff --git a/internal/tui/app.go b/internal/tui/app.go
index 433a5ad..4b31c38 100644
--- a/internal/tui/app.go
+++ b/internal/tui/app.go
@@ -205,6 +205,11 @@ func (m AppModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.historyBox.filter = HistoryFilter(msg)
cmds = append(cmds, m.refreshCmd)
+ case openReportModal:
+ if m.selectedBox == HistoryBox && m.historyBox.viewLevel == HistoryLevelSummary {
+ m.openReportModal()
+ }
+
}
return m, tea.Batch(cmds...)
@@ -252,10 +257,10 @@ func (m *AppModel) openHistoryFilterModal() {
var dateRangeStr string
if filter.EndDate == nil {
// Use "since <date>" format for open-ended ranges
- dateRangeStr = fmt.Sprintf("since %s", filter.StartDate.Format("2006-01-02"))
+ dateRangeStr = fmt.Sprintf("since %s", filter.StartDate.Format(time.DateOnly))
} else {
// Use "YYYY-MM-DD to YYYY-MM-DD" format for bounded ranges
- dateRangeStr = fmt.Sprintf("%s to %s", filter.StartDate.Format("2006-01-02"), filter.EndDate.Format("2006-01-02"))
+ dateRangeStr = fmt.Sprintf("%s to %s", filter.StartDate.Format(time.DateOnly), filter.EndDate.Format(time.DateOnly))
}
m.modalBox.form.fields[0].SetValue(dateRangeStr)
@@ -282,6 +287,41 @@ func (m *AppModel) openHistoryFilterModal() {
}
}
+func (m *AppModel) openReportModal() {
+ m.modalBox.activate(ModalTypeGenerateReport, 0, *m)
+ m.modalBox.form.fields[0].Focus()
+
+ filter := m.historyBox.filter
+
+ var dateRangeStr string
+ if filter.EndDate == nil {
+ dateRangeStr = fmt.Sprintf("since %s", filter.StartDate.Format(time.DateOnly))
+ } else {
+ dateRangeStr = fmt.Sprintf("%s to %s", filter.StartDate.Format(time.DateOnly), filter.EndDate.Format(time.DateOnly))
+ }
+ m.modalBox.form.fields[1].SetValue(dateRangeStr)
+
+ if filter.ClientID != nil {
+ for _, client := range m.projectsBox.clients {
+ if client.ID == *filter.ClientID {
+ m.modalBox.form.fields[2].SetValue(client.Name)
+ break
+ }
+ }
+ }
+
+ if filter.ProjectID != nil {
+ for _, clientProjects := range m.projectsBox.projects {
+ for _, project := range clientProjects {
+ if project.ID == *filter.ProjectID {
+ m.modalBox.form.fields[3].SetValue(project.Name)
+ break
+ }
+ }
+ }
+ }
+}
+
// View renders the app
func (m AppModel) View() string {
if m.width == 0 || m.height == 0 {