summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorT <t@tjp.lol>2025-08-19 12:12:54 -0600
committerT <t@tjp.lol>2025-08-19 12:13:26 -0600
commit70dcaa2f10591ae76d908c93980babe205e4a884 (patch)
tree8b59d45f723c84d15b69235ffcf8268b89779616
parent3cd97f651e02205d0d6f554a83da1ff7efe73609 (diff)
[f] key on projects box to filter the history view to the selected client or project
-rw-r--r--internal/tui/app.go16
-rw-r--r--internal/tui/commands.go5
-rw-r--r--internal/tui/keys.go10
3 files changed, 31 insertions, 0 deletions
diff --git a/internal/tui/app.go b/internal/tui/app.go
index d21df5c..6bcc77d 100644
--- a/internal/tui/app.go
+++ b/internal/tui/app.go
@@ -226,11 +226,27 @@ func (m AppModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.openReportModal()
}
+ case filterHistoryByProjectBox:
+ if m.selectedBox == ProjectsBox {
+ m.filterHistoryByProjectBox()
+ }
+ cmds = append(cmds, m.refreshCmd)
}
return m, tea.Batch(cmds...)
}
+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
+ }
+}
+
func (m *AppModel) openEntryEditor() {
m.modalBox.activate(ModalTypeEntry, m.historyBox.selectedEntry().ID, *m)
m.modalBox.form.fields[0].Focus()
diff --git a/internal/tui/commands.go b/internal/tui/commands.go
index 66a0c4d..4fdd9e0 100644
--- a/internal/tui/commands.go
+++ b/internal/tui/commands.go
@@ -23,6 +23,7 @@ type (
openTimeEntryEditor struct{}
openContractorEditor struct{}
openClientOrProjectEditor struct{}
+ filterHistoryByProjectBox struct{}
openModalUnchanged struct{}
openDeleteConfirmation struct{}
recheckBounds struct{}
@@ -110,6 +111,10 @@ func editClientOrProject() tea.Cmd {
return func() tea.Msg { return openClientOrProjectEditor{} }
}
+func filterHistoryFromProjectBox() tea.Cmd {
+ return func() tea.Msg { return filterHistoryByProjectBox{} }
+}
+
func reOpenModal() tea.Cmd {
return func() tea.Msg { return openModalUnchanged{} }
}
diff --git a/internal/tui/keys.go b/internal/tui/keys.go
index 5cbefa4..c4ccad3 100644
--- a/internal/tui/keys.go
+++ b/internal/tui/keys.go
@@ -118,6 +118,16 @@ var Bindings map[KeyBindingScope]map[string]KeyBinding = map[KeyBindingScope]map
},
Result: func(*AppModel) tea.Cmd { return editClientOrProject() },
},
+ "f": KeyBinding{
+ Key: "f",
+ Description: func(m AppModel) string {
+ if m.projectsBox.selectedProject != nil {
+ return "Filter to Project"
+ }
+ return "Filter to Client"
+ },
+ Result: func(*AppModel) tea.Cmd { return filterHistoryFromProjectBox() },
+ },
"down": KeyBinding{
Key: "down",
Description: func(AppModel) string { return "Down" },