diff --git a/rest/compton_data/digest_properties.go b/rest/compton_data/digest_properties.go index c346506..a4586cd 100644 --- a/rest/compton_data/digest_properties.go +++ b/rest/compton_data/digest_properties.go @@ -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, diff --git a/rest/compton_fragments/search_form.go b/rest/compton_fragments/search_form.go index 11050ba..a2e137f 100644 --- a/rest/compton_fragments/search_form.go +++ b/rest/compton_fragments/search_form.go @@ -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) @@ -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) @@ -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], ", ") @@ -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) } } diff --git a/rest/compton_pages/search.go b/rest/compton_pages/search.go index 052a486..ea3fbcb 100644 --- a/rest/compton_pages/search.go +++ b/rest/compton_pages/search.go @@ -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 { diff --git a/rest/get_search.go b/rest/get_search.go index 1518305..6124bd6 100644 --- a/rest/get_search.go +++ b/rest/get_search.go @@ -95,20 +95,18 @@ 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) @@ -116,10 +114,4 @@ func GetSearch(w http.ResponseWriter, r *http.Request) { 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 - //} }