Clean up task editor and time editor

This commit is contained in:
Martin Pander
2026-02-17 20:57:21 +01:00
parent 6e60698526
commit 1a9fd9b4b0
10 changed files with 141 additions and 115 deletions

View File

@@ -3,7 +3,6 @@ package pages
import (
"fmt"
"log/slog"
"strings"
"tasksquire/common"
"time"
@@ -510,6 +509,9 @@ func NewTaskEdit(com *common.Common, task *taskwarrior.Task, isNew bool) *taskEd
udaValues := make(map[string]*string)
for _, uda := range com.Udas {
if uda.Name == "parenttask" {
continue
}
switch uda.Type {
case taskwarrior.UdaTypeNumeric:
val := ""
@@ -691,13 +693,9 @@ type tagEdit struct {
fields []huh.Field
cursor int
newTagsValue *string
}
func NewTagEdit(common *common.Common, selected *[]string, options []string) *tagEdit {
newTags := ""
defaultKeymap := huh.NewDefaultKeyMap()
t := tagEdit{
@@ -711,14 +709,7 @@ func NewTagEdit(common *common.Common, selected *[]string, options []string) *ta
Filterable(true).
WithKeyMap(defaultKeymap).
WithTheme(common.Styles.Form),
huh.NewInput().
Title("New Tags").
Value(&newTags).
Inline(true).
Prompt(": ").
WithTheme(common.Styles.Form),
},
newTagsValue: &newTags,
}
return &t
@@ -1173,13 +1164,6 @@ func (p *TaskEditorPage) updateTasksCmd() tea.Msg {
// p.task.Project = *p.areas[0].(*taskEdit).newProjectName
// }
if *(p.areas[1].(*tagEdit).newTagsValue) != "" {
newTags := strings.Split(*p.areas[1].(*tagEdit).newTagsValue, " ")
if len(newTags) > 0 {
p.task.Tags = append(p.task.Tags, newTags...)
}
}
// Sync timestamp fields from the timeEdit area (area 2)
p.areas[2].(*timeEdit).syncToTaskFields()

View File

@@ -568,7 +568,15 @@ func (p *TimeEditorPage) View() string {
helpStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("8"))
sections = append(sections, helpStyle.Render("tab/shift+tab: navigate • enter: select/save • esc: cancel"))
return lipgloss.JoinVertical(lipgloss.Left, sections...)
content := lipgloss.JoinVertical(lipgloss.Left, sections...)
return lipgloss.Place(
p.common.Width(),
p.common.Height(),
lipgloss.Left,
lipgloss.Top,
content,
)
}
func (p *TimeEditorPage) SetSize(width, height int) {