get select edit, read, and delete working

This commit is contained in:
Travis Shears 2025-10-02 19:56:33 +02:00
parent b680a2f5d7
commit 99548e67b7
5 changed files with 62 additions and 13 deletions

View file

@ -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 {