github.com/kyleu/dbaudit@v0.0.2-0.20240321155047-ff2f2c940496/views/components/edit/String.html (about) 1 <!-- Content managed by Project Forge, see [projectforge.md] for details. --> 2 {% import ( 3 "github.com/kyleu/dbaudit/app/controller/cutil" 4 "github.com/kyleu/dbaudit/views/components" 5 ) %} 6 7 {% func String(key string, id string, value string, placeholder ...string) %}{% stripspace %} 8 {% if id == "" %} 9 <input name="{%s key %}" value="{%s value %}"{%= components.PlaceholderFor(placeholder) %} /> 10 {% else %} 11 <input id="{%s id %}" name="{%s key %}" value="{%s value %}"{%= components.PlaceholderFor(placeholder) %} /> 12 {% endif %} 13 {% endstripspace %}{% endfunc %} 14 15 {% func StringVertical(key string, id string, title string, value string, indent int, help ...string) %}{% stripspace %} 16 {%- code id = cutil.CleanID(key, id) -%} 17 <div class="mb expanded"> 18 {%= components.Indent(true, indent + 1) %} 19 <label for="{%s id %}"><em class="title">{%s title %}</em></label> 20 {%= components.Indent(true, indent + 1) %} 21 <div class="mt">{%= String(key, id, value, help...) %}</div> 22 {%= components.Indent(true, indent) %} 23 </div> 24 {% endstripspace %}{% endfunc %} 25 26 {% func StringTable(key string, id string, title string, value string, indent int, help ...string) %}{% stripspace %} 27 {%- code id = cutil.CleanID(key, id) -%} 28 <tr> 29 {%= components.Indent(true, indent + 1) %} 30 <th class="shrink"><label for="{%s id %}"{%= components.TitleFor(help) %}>{%s title %}</label></th> 31 {%= components.Indent(true, indent + 1) %} 32 <td>{%= String(key, id, value, help...) %}</td> 33 {%= components.Indent(true, indent) %} 34 </tr> 35 {% endstripspace %}{% endfunc %} 36 37 {% func Password(key string, id string, value string, placeholder ...string) %}{% stripspace %} 38 {% if id == "" %} 39 <input name="{%s key %}" type="password" value="{%s value %}"{%= components.PlaceholderFor(placeholder) %} /> 40 {% else %} 41 <input id="{%s id %}" name="{%s key %}" type="password" value="{%s value %}"{%= components.PlaceholderFor(placeholder) %} /> 42 {% endif %} 43 {% endstripspace %}{% endfunc %} 44 45 {% func PasswordVertical(key string, id string, title string, value string, indent int, help ...string) %}{% stripspace %} 46 {%- code id = cutil.CleanID(key, id) -%} 47 <div class="mb expanded"> 48 {%= components.Indent(true, indent + 1) %} 49 <label for="{%s id %}"><em class="title">{%s title %}</em></label> 50 {%= components.Indent(true, indent + 1) %} 51 <div class="mt">{%= Password(key, id, value, help...) %}</div> 52 {%= components.Indent(true, indent) %} 53 </div> 54 {% endstripspace %}{% endfunc %} 55 56 {% func PasswordTable(key string, id string, title string, value string, indent int, help ...string) %}{% stripspace %} 57 {%- code id = cutil.CleanID(key, id) -%} 58 <tr> 59 {%= components.Indent(true, indent + 1) %} 60 <th class="shrink"><label for="{%s id %}"{%= components.TitleFor(help) %}>{%s title %}</label></th> 61 {%= components.Indent(true, indent + 1) %} 62 <td>{%= Password(key, id, value, help...) %}</td> 63 {%= components.Indent(true, indent) %} 64 </tr> 65 {% endstripspace %}{% endfunc %} 66 67 {% func Textarea(key string, id string, rows int, value string, placeholder ...string) %}{% stripspace %} 68 {% if id == "" %} 69 <textarea rows="{%d rows %}" name="{%s key %}"{%= components.PlaceholderFor(placeholder) %}>{%s value %}</textarea> 70 {% else %} 71 <textarea rows="{%d rows %}" id="{%s id %}" name="{%s key %}"{%= components.PlaceholderFor(placeholder) %}>{%s value %}</textarea> 72 {% endif %} 73 {% endstripspace %}{% endfunc %} 74 75 {% func TextareaVertical(key string, id string, title string, rows int, value string, indent int, help ...string) %}{% stripspace %} 76 {%- code id = cutil.CleanID(key, id) -%} 77 <div class="mb expanded"> 78 {%= components.Indent(true, indent + 1) %} 79 <label for="{%s id %}"><em class="title">{%s title %}</em></label> 80 {%= components.Indent(true, indent + 1) %} 81 <div class="mt">{%= Textarea(key, id, rows, value, help...) %}</div> 82 {%= components.Indent(true, indent) %} 83 </div> 84 {% endstripspace %}{% endfunc %} 85 86 {% func TextareaTable(key string, id string, title string, rows int, value string, indent int, help ...string) %}{% stripspace %} 87 {%- code id = cutil.CleanID(key, id) -%} 88 <tr> 89 {%= components.Indent(true, indent + 1) %} 90 <th class="shrink"><label for="{%s id %}"{%= components.TitleFor(help) %}>{%s title %}</label></th> 91 {%= components.Indent(true, indent + 1) %} 92 <td>{%= Textarea(key, id, rows, value, help...) %}</td> 93 {%= components.Indent(true, indent) %} 94 </tr> 95 {% endstripspace %}{% endfunc %}