Core

/views/components/edit/Timestamp.html (3.1 KB)

 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
58
59
60
61
62
63
64
65
66
67
{% import (
"time"

"{{{ .Package }}}/app/controller/cutil"
"{{{ .Package }}}/app/util"
"{{{ .Package }}}/views/components"
) %}

{% func Timestamp(key string, id string, value *time.Time, placeholder ...string) %}{% stripspace %}
{% if id == "" %}
<input name="{%s key %}" type="datetime-local" value="{%s util.TimeToFull(value) %}"{%= components.PlaceholderFor(placeholder) %} />
{% else %}
<input id="{%s id %}" name="{%s key %}" type="datetime-local" value="{%s util.TimeToFull(value) %}"{%= components.PlaceholderFor(placeholder) %} />
{% endif %}
{% endstripspace %}{% endfunc %}

{% func TimestampVertical(key string, id string, title string, value *time.Time, indent int, help ...string) %}{% stripspace %}
{%- code id = cutil.CleanID(key, id) -%}
<div class="mb expanded">
{%= components.Indent(true, indent + 1) %}
<label for="{%s id %}"><em class="title">{%s title %}</em></label>
{%= components.Indent(true, indent + 1) %}
<div class="mt">{%= Timestamp(key, id, value, help...) %}</div>
{%= components.Indent(true, indent) %}
</div>
{% endstripspace %}{% endfunc %}

{% func TimestampTable(key string, id string, title string, value *time.Time, indent int, help ...string) %}{% stripspace %}
{%- code id = cutil.CleanID(key, id) -%}
<tr>
{%= components.Indent(true, indent + 1) %}
<th class="shrink"><label for="{%s id %}"{%= components.TitleFor(help) %}>{%s title %}</label></th>
{%= components.Indent(true, indent + 1) %}
<td>{%= Timestamp(key, id, value, help...) %}</td>
{%= components.Indent(true, indent) %}
</tr>
{% endstripspace %}{% endfunc %}

{% func TimestampDay(key string, id string, value *time.Time, placeholder ...string) %}{% stripspace %}
{% if id == "" %}
<input name="{%s key %}" type="date" value="{%s util.TimeToYMD(value) %}"{%= components.PlaceholderFor(placeholder) %} />
{% else %}
<input id="{%s id %}" name="{%s key %}" type="date" value="{%s util.TimeToYMD(value) %}"{%= components.PlaceholderFor(placeholder) %} />
{% endif %}
{% endstripspace %}{% endfunc %}

{% func TimestampDayVertical(key string, id string, title string, value *time.Time, indent int, help ...string) %}{% stripspace %}
{%- code id = cutil.CleanID(key, id) -%}
<div class="mb expanded">
{%= components.Indent(true, indent + 1) %}
<label for="{%s id %}"><em class="title">{%s title %}</em></label>
{%= components.Indent(true, indent + 1) %}
<div class="mt">{%= TimestampDay(key, id, value, help...) %}</div>
{%= components.Indent(true, indent) %}
</div>
{% endstripspace %}{% endfunc %}

{% func TimestampDayTable(key string, id string, title string, value *time.Time, indent int, help ...string) %}{% stripspace %}
{%- code id = cutil.CleanID(key, id) -%}
<tr>
{%= components.Indent(true, indent + 1) %}
<th class="shrink"><label for="{%s id %}"{%= components.TitleFor(help) %}>{%s title %}</label></th>
{%= components.Indent(true, indent + 1) %}
<td>{%= TimestampDay(key, id, value, help...) %}</td>
{%= components.Indent(true, indent) %}
</tr>
{% endstripspace %}{% endfunc %}