1
0
Fork 0

Fixed system selection

This commit is contained in:
マリウス 2023-01-04 23:59:59 -05:00
parent 8af4f3469e
commit df99e56ee2
No known key found for this signature in database
GPG Key ID: 272ED814BF63261F
2 changed files with 11 additions and 2 deletions

View File

@ -74,7 +74,7 @@ func (m Model) View() string {
curSysIdx := m.ctx.GetCurrentSystem()
var currentSystem string = "All"
if curSysIdx >= 0 {
currentSystem = string((*m.ctx.Systems[curSysIdx]).GetID())
currentSystem = (*m.ctx.Systems[curSysIdx]).Title()
}
systemSelector := selector.Render(fmt.Sprintf("⏷ %s", currentSystem))

View File

@ -103,6 +103,11 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, tea.Batch(ccmds...)
case key.Matches(msg, m.keymap.SystemSelect):
var listItems []list.Item
all, _ := system.New("all", nil, m.ctx.Logger)
all.SetID(-1)
listItems = append(listItems, all)
for _, sys := range m.ctx.Systems {
listItems = append(listItems, *sys)
}
@ -185,7 +190,11 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case postcreate.WIN_ID:
m.ctx.Logger.Debugln("received WinClose")
case popuplist.WIN_ID:
switch msg.GetArg("selectionID").(string) {
selectionIDIf := msg.GetArg("selectionID")
if selectionIDIf == nil {
return m, nil
}
switch selectionIDIf.(string) {
case "system":
selected := msg.GetArg("selected").(system.System)
m.ctx.SetCurrentSystem(selected.GetID())