diff --git a/templates/components/filter_bar.gohtml b/templates/components/filter_bar.gohtml index 35b3ca0..200e68a 100644 --- a/templates/components/filter_bar.gohtml +++ b/templates/components/filter_bar.gohtml @@ -1,4 +1,6 @@ {{define "filter_bar"}} +{{$selectedGenreIDs := .Genres}} +{{$selectedCount := len $selectedGenreIDs}}
@@ -11,14 +13,45 @@ class="focus:ring-accent w-full bg-black/20 px-3 py-2 text-sm text-white placeholder-neutral-500 outline-none focus:ring-1" onkeydown="if(event.key === 'Enter'){this.form.submit()}" /> - {{if .Type}}{{end}} {{if .Status}}{{end}} {{if .OrderBy}}{{end}} {{if .Sort}}{{end}} + {{range $g := .Genres}}{{end}}
+ +
+ +
+ +
+
@@ -45,12 +78,12 @@
@@ -65,17 +98,17 @@ - + {{if eq .Sort "asc"}} {{else}} diff --git a/templates/renderer.go b/templates/renderer.go index 46febe6..3065099 100644 --- a/templates/renderer.go +++ b/templates/renderer.go @@ -41,6 +41,24 @@ func GetRenderer() *Renderer { b, _ := json.Marshal(v) return template.HTMLAttr(b) }, + "genresParams": func(genres []int) string { + if len(genres) == 0 { + return "" + } + s := "" + for _, g := range genres { + s += "genres=" + fmt.Sprintf("%d", g) + "&" + } + return s[:len(s)-1] + }, + "hasGenre": func(id int, genres []int) bool { + for _, g := range genres { + if g == id { + return true + } + } + return false + }, } pages, err := filepath.Glob(filepath.Join(".", "templates", "*.gohtml"))