1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| {% import ( "strconv"
"{{{ .Package }}}/app" "{{{ .Package }}}/app/controller/cutil" "{{{ .Package }}}/views/components" "{{{ .Package }}}/views/layout" ) %}
{% code type Args struct { layout.Basic URL string Directions string ArgRes *cutil.ArgResults Hidden map[string]string } %}
{% func (p *Args) Body(as *app.State, ps *cutil.PageState) %} <div class="card"> <h3>{% if p.Directions == "" %}Enter Data{% else %}{%s p.Directions %}{% endif %}</h3> <form action="{%s p.URL %}" method="get"> {%- for k, v := range p.Hidden -%} <input type="hidden" name="{%s k %}" value="{%s v %}" /> {%- endfor -%} <div class="overflow full-width"> <table class="mt min-200 expanded"> <tbody> {%- for _, arg := range p.ArgRes.Args -%} {%- code v := p.ArgRes.Values[arg.Key] if v == "" { v = arg.Default } title := arg.Title if len(title) > 50 { title = title[:50] + "..." } -%} {%- switch arg.Type -%} {%- case "bool" -%} {%= components.TableBoolean(arg.Key, title, v == "true", 5, arg.Description) %} {%- case "textarea" -%} {%= components.TableTextarea(arg.Key, "", title, 12, v, 5, arg.Description) %} {%- case "number", "int" -%} {%- code i, _ := strconv.ParseInt(v, 10, 32) -%} {%= components.TableInputNumber(arg.Key, "", title, int(i), 5, arg.Description) %} {%- default -%} {%= components.TableDatalist(arg.Key, "", title, v, arg.Choices, nil, 5, arg.Description) %} {%- endswitch -%} {%- endfor -%} </tbody> </table> </div> <button class="mt" type="submit">Submit</button> </form> </div> {% endfunc %}
|