summaryrefslogtreecommitdiff
path: root/internal/tui/history_box.go
diff options
context:
space:
mode:
authorT <t@tjp.lol>2025-08-07 13:11:24 -0600
committerT <t@tjp.lol>2025-08-07 23:14:00 -0600
commita7ee7f7280d593481501446008acc05e32abcd22 (patch)
treef056bd9c72934a9e04aa5af872e836bc43d3739f /internal/tui/history_box.go
parent4843deb9cfa6d91282c5124ec025c636137e9e94 (diff)
entry edit and delete
Diffstat (limited to 'internal/tui/history_box.go')
-rw-r--r--internal/tui/history_box.go28
1 files changed, 27 insertions, 1 deletions
diff --git a/internal/tui/history_box.go b/internal/tui/history_box.go
index 847b4fc..99fa4ac 100644
--- a/internal/tui/history_box.go
+++ b/internal/tui/history_box.go
@@ -262,7 +262,7 @@ func (m HistoryBoxModel) renderSummaryView(timer TimerBoxModel) string {
for i, item := range m.summaryItems {
if date == nil || !date.Equal(item.Date) {
date = &item.Date
- content += fmt.Sprintf("\n\n%s\n", dateStyle.Render(date.Format("Mon 2006/01/02")))
+ content += fmt.Sprintf("\n\n%s\n", dateStyle.Render(date.Format("Mon 01/02")))
}
style := summaryItemStyle
@@ -409,6 +409,13 @@ func (m *HistoryBoxModel) changeDetailsSelection(forward bool) {
}
}
+func (m HistoryBoxModel) selectedEntry() queries.TimeEntry {
+ if m.viewLevel != HistoryLevelDetails {
+ panic("fetching selected entry in history summary level")
+ }
+ return m.selectedEntries()[m.detailSelection]
+}
+
func (m HistoryBoxModel) selection() (string, string, string, *float64) {
item := m.summaryItems[m.summarySelection]
@@ -444,3 +451,22 @@ func (m *HistoryBoxModel) drillDown() {
func (m *HistoryBoxModel) drillUp() {
m.viewLevel = HistoryLevelSummary
}
+
+func (m *HistoryBoxModel) recheckBounds() {
+ for m.summarySelection >= len(m.summaryItems) {
+ m.summarySelection--
+ }
+ if m.summarySelection < 0 {
+ m.summarySelection = 0
+ }
+
+ if m.viewLevel == HistoryLevelDetails {
+ ents := m.selectedEntries()
+ for m.detailSelection >= len(ents) {
+ m.detailSelection--
+ }
+ if m.detailSelection < 0 {
+ m.detailSelection = 0
+ }
+ }
+}