[WIP] Task editing
This commit is contained in:
@ -17,6 +17,7 @@ func NewMainPage(common *common.Common) *MainPage {
|
||||
}
|
||||
|
||||
m.activePage = NewReportPage(common, common.TW.GetReport(common.TW.GetConfig().Get("uda.tasksquire.report.default")))
|
||||
// m.activePage = NewTaskEditorPage(common, taskwarrior.Task{})
|
||||
|
||||
return m
|
||||
|
||||
|
||||
69
pages/messaging.go
Normal file
69
pages/messaging.go
Normal file
@ -0,0 +1,69 @@
|
||||
package pages
|
||||
|
||||
import tea "github.com/charmbracelet/bubbletea"
|
||||
|
||||
type UpdatedTasksMsg struct{}
|
||||
|
||||
type nextColumnMsg struct{}
|
||||
|
||||
func nextColumn() tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
return nextColumnMsg{}
|
||||
}
|
||||
}
|
||||
|
||||
type prevColumnMsg struct{}
|
||||
|
||||
func prevColumn() tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
return prevColumnMsg{}
|
||||
}
|
||||
}
|
||||
|
||||
type nextFieldMsg struct{}
|
||||
|
||||
func nextField() tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
return nextFieldMsg{}
|
||||
}
|
||||
}
|
||||
|
||||
type prevFieldMsg struct{}
|
||||
|
||||
func prevField() tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
return prevFieldMsg{}
|
||||
}
|
||||
}
|
||||
|
||||
type nextAreaMsg struct{}
|
||||
|
||||
func nextArea() tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
return nextAreaMsg{}
|
||||
}
|
||||
}
|
||||
|
||||
type prevAreaMsg struct{}
|
||||
|
||||
func prevArea() tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
return prevAreaMsg{}
|
||||
}
|
||||
}
|
||||
|
||||
type changeAreaMsg area
|
||||
|
||||
func changeArea(a area) tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
return changeAreaMsg(a)
|
||||
}
|
||||
}
|
||||
|
||||
func changeMode(mode mode) tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
return changeModeMsg(mode)
|
||||
}
|
||||
}
|
||||
|
||||
type changeModeMsg mode
|
||||
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1095
pages/taskEditor.go
1095
pages/taskEditor.go
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user