github.com/kyleu/dbaudit@v0.0.2-0.20240321155047-ff2f2c940496/views/components/edit/Bool.html (about) 1 <!-- Content managed by Project Forge, see [projectforge.md] for details. --> 2 {% import ( 3 "fmt" 4 5 "github.com/kyleu/dbaudit/app/util" 6 ) %} 7 8 {% func Bool(key string, id string, x any, nullable bool) %}{% stripspace %} 9 {% code b, isBool := x.(bool) %} 10 {% if isBool && b %} 11 <label class="radiolabel"><input value="{%s util.BoolTrue %}" name="{%s key %}" type="radio" checked="checked" /> {%s util.BoolTrue %}</label> 12 {% else %} 13 <label class="radiolabel"><input value="{%s util.BoolTrue %}" name="{%s key %}" type="radio" /> {%s util.BoolTrue %}</label> 14 {% endif %} 15 16 {% if isBool && !b %} 17 <label class="radiolabel"><input value="{%s util.BoolFalse %}" name="{%s key %}" type="radio" checked="checked" /> {%s util.BoolFalse %}</label> 18 {% else %} 19 <label class="radiolabel"><input value="{%s util.BoolFalse %}" name="{%s key %}" type="radio" /> {%s util.BoolFalse %}</label> 20 {% endif %} 21 22 {% if nullable %} 23 {% if x == nil %} 24 <label class="radiolabel"><input value="∅" name="{%s key %}" type="radio" checked="checked" /> nil</label> 25 {% else %} 26 <label class="radiolabel"><input value="∅" name="{%s key %}" type="radio" /> nil</label> 27 {% endif %} 28 {% endif %} 29 {% endstripspace %}{% endfunc %} 30 31 {% func BoolVertical(key string, title string, value bool, indent int, help ...string) %}{% stripspace %} 32 {%= RadioVertical(key, title, fmt.Sprint(value), []string{util.BoolTrue, util.BoolFalse}, []string{"True", "False"}, indent) %} 33 {% endstripspace %}{% endfunc %} 34 35 {% func BoolTable(key string, title string, value bool, indent int, help ...string) %}{% stripspace %} 36 {%= RadioTable(key, title, fmt.Sprint(value), []string{util.BoolTrue, util.BoolFalse}, []string{"True", "False"}, indent) %} 37 {% endstripspace %}{% endfunc %}