github.com/kyleu/dbaudit@v0.0.2-0.20240321155047-ff2f2c940496/views/components/edit/Timestamp.html (about) 1 <!-- Content managed by Project Forge, see [projectforge.md] for details. --> 2 {% import ( 3 "time" 4 5 "github.com/kyleu/dbaudit/app/controller/cutil" 6 "github.com/kyleu/dbaudit/app/util" 7 "github.com/kyleu/dbaudit/views/components" 8 ) %} 9 10 {% func Timestamp(key string, id string, value *time.Time, placeholder ...string) %}{% stripspace %} 11 {% if id == "" %} 12 <input name="{%s key %}" type="datetime-local" value="{%s util.TimeToFull(value) %}"{%= components.PlaceholderFor(placeholder) %} /> 13 {% else %} 14 <input id="{%s id %}" name="{%s key %}" type="datetime-local" value="{%s util.TimeToFull(value) %}"{%= components.PlaceholderFor(placeholder) %} /> 15 {% endif %} 16 {% endstripspace %}{% endfunc %} 17 18 {% func TimestampVertical(key string, id string, title string, value *time.Time, indent int, help ...string) %}{% stripspace %} 19 {%- code id = cutil.CleanID(key, id) -%} 20 <div class="mb expanded"> 21 {%= components.Indent(true, indent + 1) %} 22 <label for="{%s id %}"><em class="title">{%s title %}</em></label> 23 {%= components.Indent(true, indent + 1) %} 24 <div class="mt">{%= Timestamp(key, id, value, help...) %}</div> 25 {%= components.Indent(true, indent) %} 26 </div> 27 {% endstripspace %}{% endfunc %} 28 29 {% func TimestampTable(key string, id string, title string, value *time.Time, indent int, help ...string) %}{% stripspace %} 30 {%- code id = cutil.CleanID(key, id) -%} 31 <tr> 32 {%= components.Indent(true, indent + 1) %} 33 <th class="shrink"><label for="{%s id %}"{%= components.TitleFor(help) %}>{%s title %}</label></th> 34 {%= components.Indent(true, indent + 1) %} 35 <td>{%= Timestamp(key, id, value, help...) %}</td> 36 {%= components.Indent(true, indent) %} 37 </tr> 38 {% endstripspace %}{% endfunc %} 39 40 {% func TimestampDay(key string, id string, value *time.Time, placeholder ...string) %}{% stripspace %} 41 {% if id == "" %} 42 <input name="{%s key %}" type="date" value="{%s util.TimeToYMD(value) %}"{%= components.PlaceholderFor(placeholder) %} /> 43 {% else %} 44 <input id="{%s id %}" name="{%s key %}" type="date" value="{%s util.TimeToYMD(value) %}"{%= components.PlaceholderFor(placeholder) %} /> 45 {% endif %} 46 {% endstripspace %}{% endfunc %} 47 48 {% func TimestampDayVertical(key string, id string, title string, value *time.Time, indent int, help ...string) %}{% stripspace %} 49 {%- code id = cutil.CleanID(key, id) -%} 50 <div class="mb expanded"> 51 {%= components.Indent(true, indent + 1) %} 52 <label for="{%s id %}"><em class="title">{%s title %}</em></label> 53 {%= components.Indent(true, indent + 1) %} 54 <div class="mt">{%= TimestampDay(key, id, value, help...) %}</div> 55 {%= components.Indent(true, indent) %} 56 </div> 57 {% endstripspace %}{% endfunc %} 58 59 {% func TimestampDayTable(key string, id string, title string, value *time.Time, indent int, help ...string) %}{% stripspace %} 60 {%- code id = cutil.CleanID(key, id) -%} 61 <tr> 62 {%= components.Indent(true, indent + 1) %} 63 <th class="shrink"><label for="{%s id %}"{%= components.TitleFor(help) %}>{%s title %}</label></th> 64 {%= components.Indent(true, indent + 1) %} 65 <td>{%= TimestampDay(key, id, value, help...) %}</td> 66 {%= components.Indent(true, indent) %} 67 </tr> 68 {% endstripspace %}{% endfunc %}