Clean up display, add focus indication
All checks were successful
CI / test (push) Successful in 1m33s

This commit is contained in:
Justin Hawkins 2025-06-20 12:11:17 +02:00
parent d7f0ac16d4
commit e7fa789b2b
2 changed files with 24 additions and 9 deletions

View File

@ -76,10 +76,10 @@ func initialModel(miteDomain, miteApiKey string) model {
tab.SetStyles(s)
tab.SetColumns([]table.Column{
table.Column{Title: "min", Width: 5},
table.Column{Title: "lck", Width: 4},
table.Column{Title: "customer", Width: 10},
table.Column{Title: "description", Width: 40},
{Title: " min", Width: 4},
{Title: "🔐", Width: 2},
{Title: "customer", Width: 10},
{Title: "description", Width: 40},
})
m.start = calendarTime{time.Now()}
@ -304,7 +304,7 @@ func (m model) tableDataForDate(t time.Time) []table.Row {
if entry.Locked {
lock = "🔐"
}
rows = append(rows, table.Row{fmt.Sprint(entry.Minutes), lock, entry.CustomerName, entry.Note})
rows = append(rows, table.Row{fmt.Sprintf("%4d", entry.Minutes), lock, entry.CustomerName, entry.Note})
}
return rows
}
@ -346,6 +346,12 @@ func (m model) View() string {
lhs := strings.Builder{}
rhs := strings.Builder{}
nb := lipgloss.NewStyle().Border(lipgloss.NormalBorder())
db := lipgloss.NewStyle().Border(lipgloss.DoubleBorder())
lhsS := nb
rhsS := nb
// if any entries are not "locked", we always use that
// regular colour in preference
styles := map[string]lipgloss.Style{}
@ -367,6 +373,7 @@ func (m model) View() string {
if m.tuiMode == MODE_CAL {
lhs.WriteString("(f)etch time data\n")
lhsS = db
} else {
lhs.WriteString("\n")
}
@ -378,18 +385,24 @@ func (m model) View() string {
if m.tuiMode == MODE_FORMENTRY {
lhs.WriteString("(esc) abort form\n")
lhs.WriteString("\n")
rhsS = db
} else {
lhs.WriteString("(tab) switch panes\n")
lhs.WriteString("(q)uit\n")
}
if m.tuiMode == MODE_TIMEENTRIES {
rhsS = db
}
calendarWidth := 25
tableWidth := m.windowWidth - calendarWidth
lhsWidth := 25
rhsWidth := m.windowWidth - lhsWidth - 4
if m.tuiMode == MODE_FORMENTRY {
rhs.WriteString(m.formData.form.View())
} else {
if m.fetchedData {
m.timeData.table.Columns()[3].Width = rhsWidth - 30
m.timeData.table.SetHeight(14)
rhs.WriteString(m.timeData.table.View())
rhs.WriteString("\n")
}
@ -397,8 +410,8 @@ func (m model) View() string {
out := lipgloss.JoinHorizontal(
lipgloss.Top,
lipgloss.NewStyle().Width(calendarWidth).Render(lhs.String()),
lipgloss.NewStyle().Width(tableWidth).Render(rhs.String()),
lhsS.Render(lipgloss.NewStyle().Width(lhsWidth).Render(lhs.String())),
rhsS.Render(lipgloss.NewStyle().Width(rhsWidth).Render(rhs.String())),
)
sofar := lipgloss.Height(out)

View File

@ -20,6 +20,8 @@ func (m model) updateForm(msg tea.Msg) (tea.Model, tea.Cmd) {
case "esc":
m.tuiMode = MODE_CAL
return m, nil
case "ctrl+c":
return m, tea.Quit
}
}