Add details editing

This commit is contained in:
Martin
2024-06-09 21:46:39 +02:00
parent bafd8958d4
commit 98d2d041d6
5 changed files with 92 additions and 46 deletions

View File

@ -60,7 +60,7 @@ func (p *ReportPage) SetSize(width int, height int) {
}
func (p *ReportPage) Init() tea.Cmd {
return p.getTasks()
return tea.Batch(p.getTasks(), doTick())
}
func (p *ReportPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
@ -69,7 +69,11 @@ func (p *ReportPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case tea.WindowSizeMsg:
p.SetSize(msg.Width, msg.Height)
// case BackMsg:
case TaskMsg:
case tickMsg:
cmds = append(cmds, p.getTasks())
cmds = append(cmds, doTick())
return p, tea.Batch(cmds...)
case taskMsg:
p.tasks = taskwarrior.Tasks(msg)
p.populateTaskTable(p.tasks)
case UpdateReportMsg:
@ -99,7 +103,7 @@ func (p *ReportPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
p.common.PushPage(p)
return p.subpage, nil
case key.Matches(msg, p.common.Keymap.Add):
p.subpage = NewTaskEditorPage(p.common, taskwarrior.Task{})
p.subpage = NewTaskEditorPage(p.common, taskwarrior.NewTask())
p.subpage.Init()
p.common.PushPage(p)
return p.subpage, nil
@ -212,8 +216,6 @@ func (p *ReportPage) getTasks() tea.Cmd {
filters = append(filters, "project:"+p.activeProject)
}
tasks := p.common.TW.GetTasks(p.activeReport, filters...)
return TaskMsg(tasks)
return taskMsg(tasks)
}
}
type TaskMsg taskwarrior.Tasks