[WIP] Task editing
This commit is contained in:
@ -23,18 +23,31 @@ type ReportPage struct {
|
||||
|
||||
taskTable table.Model
|
||||
|
||||
subpage tea.Model
|
||||
subpageActive bool
|
||||
subpage tea.Model
|
||||
}
|
||||
|
||||
func NewReportPage(com *common.Common, report *taskwarrior.Report) *ReportPage {
|
||||
return &ReportPage{
|
||||
// return &ReportPage{
|
||||
// common: com,
|
||||
// activeReport: report,
|
||||
// activeContext: com.TW.GetActiveContext(),
|
||||
// activeProject: "",
|
||||
// taskTable: table.New(com),
|
||||
// }
|
||||
|
||||
p := &ReportPage{
|
||||
common: com,
|
||||
activeReport: report,
|
||||
activeContext: com.TW.GetActiveContext(),
|
||||
activeProject: "",
|
||||
taskTable: table.New(com),
|
||||
}
|
||||
|
||||
p.subpage = NewTaskEditorPage(p.common, taskwarrior.Task{})
|
||||
p.subpage.Init()
|
||||
p.common.PushPage(p)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *ReportPage) SetSize(width int, height int) {
|
||||
@ -53,8 +66,7 @@ func (p *ReportPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
switch msg := msg.(type) {
|
||||
case tea.WindowSizeMsg:
|
||||
p.SetSize(msg.Width, msg.Height)
|
||||
case BackMsg:
|
||||
p.subpageActive = false
|
||||
// case BackMsg:
|
||||
case TaskMsg:
|
||||
p.tasks = taskwarrior.Tasks(msg)
|
||||
p.populateTaskTable(p.tasks)
|
||||
@ -77,25 +89,21 @@ func (p *ReportPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
case key.Matches(msg, p.common.Keymap.SetReport):
|
||||
p.subpage = NewReportPickerPage(p.common, p.activeReport)
|
||||
p.subpage.Init()
|
||||
p.subpageActive = true
|
||||
p.common.PushPage(p)
|
||||
return p.subpage, nil
|
||||
case key.Matches(msg, p.common.Keymap.SetContext):
|
||||
p.subpage = NewContextPickerPage(p.common)
|
||||
p.subpage.Init()
|
||||
p.subpageActive = true
|
||||
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.Init()
|
||||
p.subpageActive = true
|
||||
p.common.PushPage(p)
|
||||
return p.subpage, nil
|
||||
case key.Matches(msg, p.common.Keymap.Edit):
|
||||
p.subpage = NewTaskEditorPage(p.common, *p.selectedTask)
|
||||
p.subpage.Init()
|
||||
p.subpageActive = true
|
||||
p.common.PushPage(p)
|
||||
return p.subpage, nil
|
||||
case key.Matches(msg, p.common.Keymap.Ok):
|
||||
@ -104,12 +112,32 @@ func (p *ReportPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
case key.Matches(msg, p.common.Keymap.SetProject):
|
||||
p.subpage = NewProjectPickerPage(p.common, p.activeProject)
|
||||
p.subpage.Init()
|
||||
p.subpageActive = true
|
||||
p.common.PushPage(p)
|
||||
return p.subpage, nil
|
||||
case key.Matches(msg, p.common.Keymap.Tag):
|
||||
if p.selectedTask != nil {
|
||||
tag := p.common.TW.GetConfig().Get("uda.tasksquire.tag.default")
|
||||
if p.selectedTask.HasTag(tag) {
|
||||
p.selectedTask.RemoveTag(tag)
|
||||
} else {
|
||||
p.selectedTask.AddTag(tag)
|
||||
}
|
||||
p.common.TW.ImportTask(p.selectedTask)
|
||||
return p, p.getTasks()
|
||||
}
|
||||
return p, nil
|
||||
case key.Matches(msg, p.common.Keymap.Undo):
|
||||
p.common.TW.Undo()
|
||||
return p, p.getTasks()
|
||||
case key.Matches(msg, p.common.Keymap.StartStop):
|
||||
if p.selectedTask != nil && p.selectedTask.Status == "pending" {
|
||||
if p.selectedTask.Start == "" {
|
||||
p.common.TW.StartTask(p.selectedTask)
|
||||
} else {
|
||||
p.common.TW.StopTask(p.selectedTask)
|
||||
}
|
||||
return p, p.getTasks()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user