Core

/views/components/view/Map.html (3.9 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
{% import (
"{{{ .Package }}}/app/controller/cutil"
"{{{ .Package }}}/app/util"
"{{{ .Package }}}/views/components"
) %}

{% func Map(preserveWhitespace bool, m util.ValueMap, ps *cutil.PageState) %}{% stripspace %}
{%- if m == nil -%}
<em>no result</em>
{%- elseif len(m) == 0 -%}
<em>empty result</em>
{%- else -%}
<div class="overflow full-width bl">
<table class="expanded">
<tbody>
{%- for _, k := range m.Keys() -%}
<tr>
<th class="shrink">{%s k %}</th>
{%- if preserveWhitespace -%}
<td class="prews">{%= Any(m[k], ps) %}</td>
{%- else -%}
<td>{%= Any(m[k], ps) %}</td>
{%- endif -%}
</tr>
{%- endfor -%}
</tbody>
</table>
</div>
{%- endif -%}
{% endstripspace %}{% endfunc %}

{% func MapTable(title string, preserveWhitespace bool, value util.ValueMap, indent int, ps *cutil.PageState) %}{% stripspace %}
<tr>
{%= components.Indent(true, indent + 1) %}
<th class="shrink">{%s title %}</th>
{%= components.Indent(true, indent + 1) %}
<td>{%= Map(preserveWhitespace, value, ps) %}</td>
{%= components.Indent(true, indent) %}
</tr>
{% endstripspace %}{% endfunc %}

{% func MapKeys(m util.ValueMap) %}{% stripspace %}
{%- if m == nil || len(m) == 0 -%}
<em>no keys</em>
{%- else -%}
{%= Tags(m.Keys(), nil) %}
{%- endif -%}
{% endstripspace %}{% endfunc %}

{% func MapArray(preserveWhitespace bool, ps *cutil.PageState, maps ...util.ValueMap) %}{% stripspace %}
{%- if len(maps) == 0 -%}
<em>no results</em>
{%- else -%}
<div class="overflow full-width">
<table>
<thead>
<tr>
{%- for _, k := range maps[0].Keys() -%}
<th>{%s k %}</th>
{%- endfor -%}
</tr>
</thead>
<tbody>
{%- for _, m := range maps -%}
<tr>
{%- for _, k := range m.Keys() -%}
{%- if preserveWhitespace -%}
<td class="prews">{%= Any(m[k], ps) %}</td>
{%- else -%}
<td>{%= Any(m[k], ps) %}</td>
{%- endif -%}
{%- endfor -%}
</tr>
{%- endfor -%}
</tbody>
</table>
</div>
{%- endif -%}
{% endstripspace %}{% endfunc %}

{% func OrderedMap(preserveWhitespace bool, m *util.OrderedMap[any], ps *cutil.PageState) %}{% stripspace %}
{%- if m == nil -%}
<em>no result</em>
{%- elseif len(m.Map) == 0 -%}
<em>empty result</em>
{%- else -%}
<div class="overflow full-width bl">
<table class="expanded">
<tbody>
{%- for _, k := range m.Order -%}
<tr>
<th class="shrink">{%s k %}</th>
{%- if preserveWhitespace -%}
<td class="prews">{%= Any(m.GetSimple(k), ps) %}</td>
{%- else -%}
<td>{%= Any(m.GetSimple(k), ps) %}</td>
{%- endif -%}
</tr>
{%- endfor -%}
</tbody>
</table>
</div>
{%- endif -%}
{% endstripspace %}{% endfunc %}

{% func OrderedMapArray(preserveWhitespace bool, ps *cutil.PageState, maps ...*util.OrderedMap[any]) %}{% stripspace %}
{%- if len(maps) == 0 -%}
<em>no results</em>
{%- else -%}
<div class="overflow full-width">
<table>
<thead>
<tr>
{%- for _, k := range maps[0].Order -%}
<th>{%s k %}</th>
{%- endfor -%}
</tr>
</thead>
<tbody>
{%- for _, m := range maps -%}
<tr>
{%- for _, k := range m.Order -%}
{%- if preserveWhitespace -%}
<td class="prews">{%= Any(m.GetSimple(k), ps) %}</td>
{%- else -%}
<td>{%= Any(m.GetSimple(k), ps) %}</td>
{%- endif -%}
{%- endfor -%}
</tr>
{%- endfor -%}
</tbody>
</table>
</div>
{%- endif -%}
{% endstripspace %}{% endfunc %}