Fix new project/tags
This commit is contained in:
@ -18,6 +18,7 @@ type ReportPage struct {
|
||||
activeContext *taskwarrior.Context
|
||||
activeProject string
|
||||
selectedTask *taskwarrior.Task
|
||||
taskCursor int
|
||||
|
||||
tasks taskwarrior.Tasks
|
||||
|
||||
@ -109,6 +110,9 @@ func (p *ReportPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
case key.Matches(msg, p.common.Keymap.Ok):
|
||||
p.common.TW.SetTaskDone(p.selectedTask)
|
||||
return p, p.getTasks()
|
||||
case key.Matches(msg, p.common.Keymap.Delete):
|
||||
p.common.TW.DeleteTask(p.selectedTask)
|
||||
return p, p.getTasks()
|
||||
case key.Matches(msg, p.common.Keymap.SetProject):
|
||||
p.subpage = NewProjectPickerPage(p.common, p.activeProject)
|
||||
p.subpage.Init()
|
||||
@ -167,7 +171,7 @@ func (p *ReportPage) populateTaskTable(tasks taskwarrior.Tasks) {
|
||||
return
|
||||
}
|
||||
|
||||
selected := 0
|
||||
selected := p.taskTable.Cursor()
|
||||
|
||||
if p.selectedTask != nil {
|
||||
for i, task := range tasks {
|
||||
@ -176,6 +180,9 @@ func (p *ReportPage) populateTaskTable(tasks taskwarrior.Tasks) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if selected > len(tasks)-1 {
|
||||
selected = len(tasks) - 1
|
||||
}
|
||||
|
||||
p.taskTable = table.New(
|
||||
p.common,
|
||||
|
||||
@ -3,6 +3,8 @@ package pages
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"slices"
|
||||
"strings"
|
||||
"tasksquire/common"
|
||||
|
||||
"tasksquire/taskwarrior"
|
||||
@ -50,6 +52,8 @@ func NewTaskEditorPage(com *common.Common, task taskwarrior.Task) *TaskEditorPag
|
||||
priorityOptions := append([]string{"(none)"}, p.common.TW.GetPriorities()...)
|
||||
projectOptions := append([]string{"(none)"}, p.common.TW.GetProjects()...)
|
||||
tagOptions := p.common.TW.GetTags()
|
||||
tagOptions = append(tagOptions, strings.Split(p.common.TW.GetConfig().Get("uda.tasksquire.tags.default"), ",")...)
|
||||
slices.Sort(tagOptions)
|
||||
|
||||
p.areas = map[area]tea.Model{
|
||||
areaTask: NewTaskEdit(p.common, &p.task.Description, &p.task.Priority, &p.task.Project, priorityOptions, projectOptions),
|
||||
@ -63,9 +67,10 @@ func NewTaskEditorPage(com *common.Common, task taskwarrior.Task) *TaskEditorPag
|
||||
|
||||
p.areaPicker = NewAreaPicker(com, []string{"Task", "Tags", "Dates"})
|
||||
|
||||
p.columnCursor = 1
|
||||
if p.task.Uuid == "" {
|
||||
// p.mode = modeInsert
|
||||
p.mode = modeNormal
|
||||
p.mode = modeInsert
|
||||
} else {
|
||||
p.mode = modeNormal
|
||||
}
|
||||
@ -173,7 +178,9 @@ func (p *TaskEditorPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
case key.Matches(msg, p.common.Keymap.Back):
|
||||
return p, changeMode(modeNormal)
|
||||
case key.Matches(msg, p.common.Keymap.Ok):
|
||||
return p, nextField()
|
||||
area, cmd := p.areas[p.area].Update(msg)
|
||||
p.areas[p.area] = area
|
||||
return p, tea.Batch(cmd, nextField())
|
||||
}
|
||||
}
|
||||
|
||||
@ -788,9 +795,15 @@ func (p *TaskEditorPage) updateTasksCmd() tea.Msg {
|
||||
if p.task.Priority == "(none)" {
|
||||
p.task.Priority = ""
|
||||
}
|
||||
// if p.additionalTags != "" {
|
||||
// p.task.Tags = append(p.task.Tags, strings.Split(p.additionalTags, " ")...)
|
||||
// }
|
||||
|
||||
if *p.areas[areaTask].(taskEdit).newProjectName != "" {
|
||||
p.task.Project = *p.areas[areaTask].(taskEdit).newProjectName
|
||||
}
|
||||
|
||||
if *p.areas[areaTags].(tagEdit).newTagsValue != "" {
|
||||
p.task.Tags = append(p.task.Tags, strings.Split(*p.areas[areaTags].(tagEdit).newTagsValue, " ")...)
|
||||
}
|
||||
|
||||
// if p.additionalProject != "" {
|
||||
// p.task.Project = p.additionalProject
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user