diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-28 10:13:52 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-28 12:50:12 +0200 |
| commit | afbdcef805dc572ee2f3a79a52fde99818715bd4 (patch) | |
| tree | cf45d6b721736399602e20923035d63d84b86287 /internal/ui/table.go | |
| parent | 72b5a6f7b2100d228a0f16171c6c08b8f311f0d4 (diff) | |
refactor(ui): break up large functions in ui package
Go/MEDIUM task (UUID d8b51046): several functions exceeded 50 lines.
Extract logical sections into focused helpers:
renderTaskDetail() (238→20 lines): delegates to detailStyles(),
renderDetailFieldRows() + per-field helpers (Priority, Tags, Due,
Project, Recur), renderDetailDescription(), renderDetailAnnotations(),
renderDetailFooter().
handleDetailFieldEdit() (128→32 lines): uses switch + shared activation
helpers (activatePriorityEdit, activateDueEdit, activateTagsEdit,
activateProjectEdit, activateRecurEdit, handleDetailDynamicFields).
handleEnterOrEdit() (120→42 lines): reuses the same shared helpers from
handlers.go; adds a taskStr closure to remove repetitive nil-guards.
View() (82→25 lines): extracts appendInlineInputOverlay() that iterates
the active editing overlays and appends the focused widget to the layout.
Also fix hardcoded Description blink index (was always 9); introduce
detailDescriptionFieldIndex() which returns 9 or 10 depending on whether
the task has a Recurrence field, matching the dynamic render position.
Clarify that Annotations are read-only in the detail view.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/ui/table.go')
| -rw-r--r-- | internal/ui/table.go | 94 |
1 files changed, 29 insertions, 65 deletions
diff --git a/internal/ui/table.go b/internal/ui/table.go index 97011ff..893f08f 100644 --- a/internal/ui/table.go +++ b/internal/ui/table.go @@ -558,7 +558,7 @@ func (m *Model) handleDescEditDone(msg descEditDoneMsg) (tea.Model, tea.Cmd) { // Reload and start blinking m.reload() - return m, m.startDetailBlink(9) // Description field index + return m, m.startDetailBlink(m.detailDescriptionFieldIndex()) } return m, nil @@ -618,7 +618,6 @@ func (m *Model) handleBlinkMsg() (tea.Model, tea.Cmd) { // View renders the table UI. func (m Model) View() string { if m.showHelp { - // Update help content before rendering m.updateHelpContent() return m.renderHelpScreen() } @@ -634,70 +633,35 @@ func (m Model) View() string { m.statusLine(), ) if m.cellExpanded { - view = lipgloss.JoinVertical(lipgloss.Left, - view, - m.expandedCellView(), - ) - } - if m.annotating { - view = lipgloss.JoinVertical(lipgloss.Left, - view, - m.annotateInput.View(), - ) - } - if m.dueEditing { - view = lipgloss.JoinVertical(lipgloss.Left, - view, - m.dueView(true), - ) - } - if m.prioritySelecting { - view = lipgloss.JoinVertical(lipgloss.Left, - view, - m.priorityView(true), - ) - } - if m.descEditing { - view = lipgloss.JoinVertical(lipgloss.Left, - view, - m.descInput.View(), - ) + view = lipgloss.JoinVertical(lipgloss.Left, view, m.expandedCellView()) } - if m.tagsEditing { - view = lipgloss.JoinVertical(lipgloss.Left, - view, - m.tagsInput.View(), - ) - } - if m.recurEditing { - view = lipgloss.JoinVertical(lipgloss.Left, - view, - m.recurInput.View(), - ) - } - if m.projEditing { - view = lipgloss.JoinVertical(lipgloss.Left, - view, - m.projInput.View(), - ) - } - if m.filterEditing { - view = lipgloss.JoinVertical(lipgloss.Left, - view, - m.filterInput.View(), - ) - } - if m.addingTask { - view = lipgloss.JoinVertical(lipgloss.Left, - view, - m.addInput.View(), - ) - } - if m.searching { - view = lipgloss.JoinVertical(lipgloss.Left, - view, - m.searchInput.View(), - ) + return m.appendInlineInputOverlay(view) +} + +// appendInlineInputOverlay appends whichever active inline-editing widget +// (annotate, due, priority, desc, tags, recur, project, filter, add, search) +// should be displayed below the table. At most one is active at a time. +func (m Model) appendInlineInputOverlay(view string) string { + type overlay struct { + active bool + widget string + } + overlays := []overlay{ + {m.annotating, m.annotateInput.View()}, + {m.dueEditing, m.dueView(true)}, + {m.prioritySelecting, m.priorityView(true)}, + {m.descEditing, m.descInput.View()}, + {m.tagsEditing, m.tagsInput.View()}, + {m.recurEditing, m.recurInput.View()}, + {m.projEditing, m.projInput.View()}, + {m.filterEditing, m.filterInput.View()}, + {m.addingTask, m.addInput.View()}, + {m.searching, m.searchInput.View()}, + } + for _, o := range overlays { + if o.active { + view = lipgloss.JoinVertical(lipgloss.Left, view, o.widget) + } } return view } |
