github.com/kyleu/dbaudit@v0.0.2-0.20240321155047-ff2f2c940496/views/components/edit/Search.html (about) 1 <!-- Content managed by Project Forge, see [projectforge.md] for details. --> 2 {% import ( 3 "strings" 4 5 "github.com/kyleu/dbaudit/app/controller/cutil" 6 "github.com/kyleu/dbaudit/views/components" 7 ) %} 8 9 {% func SearchForm(action string, fieldKey string, placeholder string, value string, ps *cutil.PageState) %}{% stripspace %} 10 {% code 11 if fieldKey == "" { 12 fieldKey = "q" 13 } 14 m := map[string]string{} 15 for k, v := range ps.URI.Query() { 16 if k == fieldKey || strings.HasSuffix(k, ".x") { 17 return 18 } 19 curr, ok := m[k] 20 if ok { 21 curr += "," 22 } 23 curr += strings.Join(v, ",") 24 m[k] = curr 25 } 26 %} 27 <form action="{%s action %}" method="get" class=""> 28 {% for k, v := range m %} 29 <input type="hidden" name="{%s k %}" value="{%s v %}" /> 30 {% endfor %} 31 <button class="right" type="submit">{%= components.SVGRef("search", 22, 22, `icon`, ps) %}</button> 32 <input class="right br0" type="search" placeholder="{%s placeholder %}" name="{%s fieldKey %}" value="{%s value %}"> 33 <div class="clear"></div> 34 </form> 35 {% endstripspace %}{% endfunc %}