get select edit, read, and delete working
This commit is contained in:
parent
b680a2f5d7
commit
99548e67b7
5 changed files with 62 additions and 13 deletions
11
entryList.go
11
entryList.go
|
|
@ -13,6 +13,8 @@ type EntryListPageModel struct {
|
|||
cursor int
|
||||
}
|
||||
|
||||
type SelectActionToTake struct{ ActionToTake Action }
|
||||
|
||||
func InitialEntryListPageModel() EntryListPageModel {
|
||||
return EntryListPageModel{
|
||||
cursor: 0,
|
||||
|
|
@ -26,6 +28,8 @@ func (m EntryListPageModel) InitEntryListPage() tea.Cmd {
|
|||
|
||||
func (m EntryListPageModel) Update(msg tea.Msg, ctx *context) (EntryListPageModel, tea.Cmd) {
|
||||
switch msg := msg.(type) {
|
||||
case SelectActionToTake:
|
||||
m.actionToTake = msg.ActionToTake
|
||||
case gemlog.GemLogsLoaded:
|
||||
m.entries = msg.Logs
|
||||
return m, nil
|
||||
|
|
@ -39,7 +43,12 @@ func (m EntryListPageModel) Update(msg tea.Msg, ctx *context) (EntryListPageMode
|
|||
if m.cursor < len(actions)-1 {
|
||||
m.cursor++
|
||||
}
|
||||
// case "enter", " ":
|
||||
case "enter", " ":
|
||||
id := m.entries[m.cursor].ID
|
||||
switch m.actionToTake {
|
||||
case Delete:
|
||||
return m, gemlog.DeleteGemlogCMD(ctx.config, id)
|
||||
}
|
||||
|
||||
// action := actions[m.cursor]
|
||||
// switch action {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue