Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Adding account tags datalist
Browse files Browse the repository at this point in the history
  • Loading branch information
boggydigital committed Oct 9, 2024
1 parent ab3668c commit c3e7d2f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion rest/compton_data/digest_properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package compton_data
import "github.com/arelate/vangogh_local_data"

var DigestProperties = []string{
//vangogh_local_data.TagIdProperty,
vangogh_local_data.TagIdProperty,
//vangogh_local_data.LocalTagsProperty,
vangogh_local_data.SteamDeckAppCompatibilityCategoryProperty,
vangogh_local_data.OperatingSystemsProperty,
Expand Down
19 changes: 16 additions & 3 deletions rest/compton_fragments/search_form.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ import (
"github.com/boggydigital/compton/elements/grid_items"
"github.com/boggydigital/compton/elements/inputs"
"github.com/boggydigital/compton/elements/title_values"
"github.com/boggydigital/kevlar"
"golang.org/x/exp/maps"
"slices"
"strings"
)

func SearchForm(r compton.Registrar, query map[string][]string, searchQueryDisplay compton.Element) compton.Element {
func SearchForm(r compton.Registrar, query map[string][]string, searchQueryDisplay compton.Element, rdx kevlar.ReadableRedux) compton.Element {

form := els.Form("/search", "GET")
formStack := flex_items.FlexItems(r, direction.Column)
Expand All @@ -36,7 +37,7 @@ func SearchForm(r compton.Registrar, query map[string][]string, searchQueryDispl
inputsGrid := grid_items.GridItems(r).JustifyContent(align.Center)
formStack.Append(inputsGrid)

searchInputs(r, query, inputsGrid)
searchInputs(r, query, inputsGrid, rdx)

// duplicating Submit button after inputs at the end
formStack.Append(submitRow)
Expand Down Expand Up @@ -113,7 +114,17 @@ func languagesDatalist() map[string]string {
return dl
}

func searchInputs(r compton.Registrar, query map[string][]string, container compton.Element) {
func tagsDatalist(rdx kevlar.ReadableRedux) map[string]string {
dl := make(map[string]string)
for _, tagId := range rdx.Keys(vangogh_local_data.TagNameProperty) {
if tagName, ok := rdx.GetLastVal(vangogh_local_data.TagNameProperty, tagId); ok {
dl[tagId] = tagName
}
}
return dl
}

func searchInputs(r compton.Registrar, query map[string][]string, container compton.Element, rdx kevlar.ReadableRedux) {
for _, property := range compton_data.SearchProperties {
title := compton_data.PropertyTitles[property]
value := strings.Join(query[property], ", ")
Expand All @@ -139,6 +150,8 @@ func searchInputs(r compton.Registrar, query map[string][]string, container comp
datalist = steamDeckDatalist()
case vangogh_local_data.LanguageCodeProperty:
datalist = languagesDatalist()
case vangogh_local_data.TagIdProperty:
datalist = tagsDatalist(rdx)
}
}

Expand Down
2 changes: 1 addition & 1 deletion rest/compton_pages/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func Search(query map[string][]string, ids []string, from, to int, rdx kevlar.Re

searchQueryDisplay := compton_fragments.SearchQueryDisplay(query, p)

filterSearchDetails.Append(compton_fragments.SearchForm(p, query, searchQueryDisplay))
filterSearchDetails.Append(compton_fragments.SearchForm(p, query, searchQueryDisplay, rdx))
pageStack.Append(filterSearchDetails)

if searchQueryDisplay != nil {
Expand Down
24 changes: 8 additions & 16 deletions rest/get_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,31 +95,23 @@ func GetSearch(w http.ResponseWriter, r *http.Request) {
return
}

// adding tag names for related games
idRedux = irx
}

tagNamesRedux, err := getRedux(http.DefaultClient, "", true, vangogh_local_data.TagNameProperty)
if err != nil {
http.Error(w, nod.Error(err).Error(), http.StatusInternalServerError)
return
}
// adding tag names for related games

if len(irx) > 0 {
idRedux = MergeIdPropertyValues(irx, tagNamesRedux)
}
tagNamesRedux, err := getRedux(http.DefaultClient, "", true, vangogh_local_data.TagNameProperty)
if err != nil {
http.Error(w, nod.Error(err).Error(), http.StatusInternalServerError)
return
}

//gaugin_middleware.DefaultHeaders(w)
idRedux = MergeIdPropertyValues(idRedux, tagNamesRedux)

rdx := kevlar.ReduxProxy(idRedux)

searchPage := compton_pages.Search(query, ids, from, to, rdx)
if err := searchPage.WriteContent(w); err != nil {
http.Error(w, nod.Error(err).Error(), http.StatusInternalServerError)
}
//return
//
//if err := app.RenderSearch(stencil_app.NavSearch, query, slice, from, to, len(ids), r.URL, rdx, w); err != nil {
// http.Error(w, nod.Error(err).Error(), http.StatusInternalServerError)
// return
//}
}

0 comments on commit c3e7d2f

Please sign in to comment.