annotate sat_templates/templates/bulma/input/field.html @ 298:1c330913ff13

bulma (tickets): renamed "tickets" to "lists"
author Goffi <goffi@goffi.org>
date Thu, 28 Jan 2021 18:42:59 +0100
parents fbea1b9a558f
children cdf88211b86b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 {# macros to create form fields #}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
249
60bf3e45d7b2 bulma (input/field): don't use kwargs anymore:
Goffi <goffi@goffi.org>
parents: 230
diff changeset
3 {% macro field(type, name, label="", value=none, class='', help="", required=false, icon_left=none, icon_right=none, attrs=none) %}
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 {# generic field
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
5 "class" keyword can be used to add classes
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 additional kwargs will be passed as attributes #}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
7
249
60bf3e45d7b2 bulma (input/field): don't use kwargs anymore:
Goffi <goffi@goffi.org>
parents: 230
diff changeset
8 <div class="field form_input {{class}}">
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 {% set cur_id = name|next_gidx %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 {% if label %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 <label for="{{cur_id}}" class="label">{{label}}</label>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 {% endif %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 <div class="control{% if icon_left %} has-icons-left{% endif %}{% if icon_right %} has-icons-right{% endif %}">
269
edefc1f25219 bulma (input/field): fixed use of `attrs` in `field`, added args, replaced use of `kwargs`
Goffi <goffi@goffi.org>
parents: 259
diff changeset
14 <input id="{{cur_id}}" class="input" type="{{type}}" name="{{name}}" {{"required" if required}}{{{'value': value}|xmlattr}}{{(attrs or {})|xmlattr}}>
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 {% if icon_left %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 <span class="icon is-left">
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 {# we use <i> with font from CSS instead of SVG, because using directly SVG doesn't play way with Bulma's control #}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 <i class="icon-{{icon_left}}"></i>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
19 </span>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
20 {% endif %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 {% if icon_right %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 <span class="icon is-right">
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 <i class="icon-{{icon_right}}"></i>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 </span>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 {% endif %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
26 </div>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
27 {% if help %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
28 <p class="help">{{help}}</p>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
29 {% endif %}
296
fbea1b9a558f bulma: new search box, used in blog for now
Goffi <goffi@goffi.org>
parents: 269
diff changeset
30 {% if caller %}
fbea1b9a558f bulma: new search box, used in blog for now
Goffi <goffi@goffi.org>
parents: 269
diff changeset
31 {{ caller() }}
fbea1b9a558f bulma: new search box, used in blog for now
Goffi <goffi@goffi.org>
parents: 269
diff changeset
32 {% endif %}
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 </div>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 {% endmacro %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
35
269
edefc1f25219 bulma (input/field): fixed use of `attrs` in `field`, added args, replaced use of `kwargs`
Goffi <goffi@goffi.org>
parents: 259
diff changeset
36 {% macro select(name, options_list, selected=none, required=false, multiple=false, class='') %}
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 {# selection of elements with <select>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
38
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 @param name: name of the field
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 @param options_list(list[str, str]): list of name, label of options
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 @param selected(none, list): list of select elements
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 @param required(bool): true this field is required
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 @param multiple(bool): true is multiple selection is possible
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
44 #}
269
edefc1f25219 bulma (input/field): fixed use of `attrs` in `field`, added args, replaced use of `kwargs`
Goffi <goffi@goffi.org>
parents: 259
diff changeset
45 <select name="{{name}}" class="form_input {{class}}" {{"required" if required}}>
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
46 {% for value, label in options_list %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
47 <option value="{{value}}" {{'selected' if selected and value in selected}}>{{label}}</option>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
48 {% endfor %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
49 </select>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 {% endmacro %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
51
269
edefc1f25219 bulma (input/field): fixed use of `attrs` in `field`, added args, replaced use of `kwargs`
Goffi <goffi@goffi.org>
parents: 259
diff changeset
52 {% macro choices(name, choices_list, checked=none, class='') %}
edefc1f25219 bulma (input/field): fixed use of `attrs` in `field`, added args, replaced use of `kwargs`
Goffi <goffi@goffi.org>
parents: 259
diff changeset
53 <div class="control {{class}}">
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
54 {% for choice, label in choices_list %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
55 <label class="radio" for="{{name|cur_gidx}}">
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
56 <input id="{{name|next_gidx}}" type="radio" name="{{name}}" value="{{choice}}"{{" checked" if checked==choice}}>{{label}}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 </label>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 {% endfor %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 </div>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 {% endmacro %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
61
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 {% macro int(name, label="", init=0) %}
249
60bf3e45d7b2 bulma (input/field): don't use kwargs anymore:
Goffi <goffi@goffi.org>
parents: 230
diff changeset
63 {{ field("number", name=name, label=label, value=init, step=1, min=0) }}
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 {% endmacro %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
65
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
66 {% macro checkbox(name, label="", checked=false) %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
67 {% set cur_id = name|next_gidx %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 <label for="{{cur_id}}" class="label checkbox">{{label}}</label>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
69 <input id="{{cur_id}}" type="checkbox" {% if checked %}checked=checked{% endif %}>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
70 {% endmacro %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
71
269
edefc1f25219 bulma (input/field): fixed use of `attrs` in `field`, added args, replaced use of `kwargs`
Goffi <goffi@goffi.org>
parents: 259
diff changeset
72 {% macro text(name, label="", value=none, class='', placeholder=none, required=false, pattern=none, title=none, autocomplete=none, icon_left=none, icon_right=none) %}
296
fbea1b9a558f bulma: new search box, used in blog for now
Goffi <goffi@goffi.org>
parents: 269
diff changeset
73 {{ field("text", name=name, label=label, value=value, class=class, required=required, icon_left=icon_left, icon_right=icon_right, attrs={'placeholder': placeholder, 'pattern': pattern, 'title': title, 'autocomplete': autocomplete}, caller=caller) }}
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
74 {% endmacro %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
75
269
edefc1f25219 bulma (input/field): fixed use of `attrs` in `field`, added args, replaced use of `kwargs`
Goffi <goffi@goffi.org>
parents: 259
diff changeset
76 {% macro password(name, label="", value=none, required=false, minlength=none, icon_left=none, icon_right=none) %}
edefc1f25219 bulma (input/field): fixed use of `attrs` in `field`, added args, replaced use of `kwargs`
Goffi <goffi@goffi.org>
parents: 259
diff changeset
77 {{ field("password", name=name, label=label, value=value, required=required, icon_left=icon_left, icon_right=icon_right, attrs={'minlength': minlength}) }}
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
78 {% endmacro %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
79
269
edefc1f25219 bulma (input/field): fixed use of `attrs` in `field`, added args, replaced use of `kwargs`
Goffi <goffi@goffi.org>
parents: 259
diff changeset
80 {% macro email(name, label="", required=false, value=none, icon_left=none, icon_right=none) %}
edefc1f25219 bulma (input/field): fixed use of `attrs` in `field`, added args, replaced use of `kwargs`
Goffi <goffi@goffi.org>
parents: 259
diff changeset
81 {{ field("email", name=name, label=label, value=value, required=required, icon_left=icon_left, icon_right=icon_right) }}
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
82 {% endmacro %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
83
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
84 {% macro date(name, label="", required=false) %}
249
60bf3e45d7b2 bulma (input/field): don't use kwargs anymore:
Goffi <goffi@goffi.org>
parents: 230
diff changeset
85 {{ field("date", name=name, label=label, required=required) }}
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
86 {% endmacro %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
87
249
60bf3e45d7b2 bulma (input/field): don't use kwargs anymore:
Goffi <goffi@goffi.org>
parents: 230
diff changeset
88 {% macro url(name, label="", class="", placeholder=none, required=false, title=none, pattern=none) %}
60bf3e45d7b2 bulma (input/field): don't use kwargs anymore:
Goffi <goffi@goffi.org>
parents: 230
diff changeset
89 {{ field("url", name=name, label=label, required=required, attrs={'placeholder': placeholder, 'title': title, 'pattern': pattern}) }}
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
90 {% endmacro %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
91
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
92 {% macro file(name, label="", required=false) %}
249
60bf3e45d7b2 bulma (input/field): don't use kwargs anymore:
Goffi <goffi@goffi.org>
parents: 230
diff changeset
93 {{ field("file", name=name, label=label, required=required) }}
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
94 {% endmacro %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
95
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
96 {% macro textarea(name, label="", rows=none, cols=50, placeholder='', help='', required=false) %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
97 <div class="field form_input">
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
98 {% set cur_id = name|next_gidx %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
99 {% if label %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
100 <label for="{{cur_id}}" class="label">{{label}}</label>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
101 {% endif %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
102 <textarea id="{{cur_id}}" name="{{name}}" {{ {"rows": rows, "cols": cols}|xmlattr }} placeholder="{{placeholder}}" {{"required" if required}} class="textarea"></textarea>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
103 {% if help %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
104 <p class="help">{{help}}</p>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
105 {% endif %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
106 </div>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
107 {% endmacro %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
108
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
109 {% macro meta(name, value) %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
110 <input type="hidden" name="{{name}}" value="{{value}}">
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
111 {% endmacro %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
112
269
edefc1f25219 bulma (input/field): fixed use of `attrs` in `field`, added args, replaced use of `kwargs`
Goffi <goffi@goffi.org>
parents: 259
diff changeset
113 {% macro submit(text=_("Send"), id=none, class='', attrs=none) %}
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
114 {# submit button
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
115
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
116 @param text(str): label of the button
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
117 @param id(none, str): id of the element
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
118 #}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
119 <div class="control {{class}}">
269
edefc1f25219 bulma (input/field): fixed use of `attrs` in `field`, added args, replaced use of `kwargs`
Goffi <goffi@goffi.org>
parents: 259
diff changeset
120 <button{{ {'id': id}|xmlattr }} class="button is-primary form_submit {{class}}" type="submit"{{(attrs or {})|xmlattr}}>{{text}}</button>
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
121 </div>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
122 {% endmacro %}