annotate sat_templates/templates/default/input/field.html @ 231:aa37750c2617

theme (default): various fixes: - added missing </tr> in event/admin.html - fixed used of identities - uses `class` from kwargs in input/field.html
author Goffi <goffi@goffi.org>
date Tue, 19 May 2020 00:04:47 +0200
parents bdc578994b97
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
153
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
1 {# macros to create form fields #}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
2
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
3 {% macro field(type, name, label="", required=false) %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
4 {# generic field
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
5 "class" keyword can be used to add classes
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
6 additional kwargs will be passed as attributes #}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
7 <span class="form_input {{kwargs.pop('class', '')}}">
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
8 {% set cur_id = name|next_gidx %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
9 {% if label %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
10 <label for="{{cur_id}}" {{'class="required"'|safe if required}}>{{label}}</label>
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
11 {% endif %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
12 <input id="{{cur_id}}" type="{{type}}" name="{{name}}" {{"required" if required}} {{kwargs|xmlattr}}>
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
13 </span>
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
14 {% endmacro %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
15
203
bdc578994b97 input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
Goffi <goffi@goffi.org>
parents: 166
diff changeset
16 {% macro select(name, options_list, selected=none, required=false, multiple=false) %}
bdc578994b97 input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
Goffi <goffi@goffi.org>
parents: 166
diff changeset
17 {# selection of elements with <select>
bdc578994b97 input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
Goffi <goffi@goffi.org>
parents: 166
diff changeset
18
bdc578994b97 input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
Goffi <goffi@goffi.org>
parents: 166
diff changeset
19 @param name: name of the field
bdc578994b97 input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
Goffi <goffi@goffi.org>
parents: 166
diff changeset
20 @param options_list(list[str, str]): list of name, label of options
bdc578994b97 input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
Goffi <goffi@goffi.org>
parents: 166
diff changeset
21 @param selected(none, list): list of select elements
bdc578994b97 input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
Goffi <goffi@goffi.org>
parents: 166
diff changeset
22 @param required(bool): true this field is required
bdc578994b97 input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
Goffi <goffi@goffi.org>
parents: 166
diff changeset
23 @param multiple(bool): true is multiple selection is possible
bdc578994b97 input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
Goffi <goffi@goffi.org>
parents: 166
diff changeset
24 #}
bdc578994b97 input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
Goffi <goffi@goffi.org>
parents: 166
diff changeset
25 <select name="{{name}}" class="form_input {{kwargs.pop('class', '')}}" {{"required" if required}}>
bdc578994b97 input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
Goffi <goffi@goffi.org>
parents: 166
diff changeset
26 {% for value, label in options_list %}
bdc578994b97 input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
Goffi <goffi@goffi.org>
parents: 166
diff changeset
27 <option value="{{value}}" {{'selected' if selected and value in selected}}>{{label}}</option>
bdc578994b97 input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
Goffi <goffi@goffi.org>
parents: 166
diff changeset
28 {% endfor %}
bdc578994b97 input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
Goffi <goffi@goffi.org>
parents: 166
diff changeset
29 </select>
bdc578994b97 input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
Goffi <goffi@goffi.org>
parents: 166
diff changeset
30 {% endmacro %}
bdc578994b97 input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
Goffi <goffi@goffi.org>
parents: 166
diff changeset
31
10
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
32 {% macro choices(name, choices_list, checked=none) %}
20
8fa2fd2e928e default: added i18n support
Goffi <goffi@goffi.org>
parents: 18
diff changeset
33 {% for choice, label in choices_list %}
153
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
34 <div class="form_input {{kwargs.pop('class', '')}}">
52
87680eed9e25 input(field, form): improved classes + new email field
Goffi <goffi@goffi.org>
parents: 46
diff changeset
35 <input id="{{name|next_gidx}}" type="radio" name="{{name}}" value="{{choice}}"{{" checked" if checked==choice}}><label for="{{name|cur_gidx}}">{{label}}</label>
18
d4a8afa7b590 input/field: <label> is separated from <input>
Goffi <goffi@goffi.org>
parents: 10
diff changeset
36 </div>
10
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
37 {% endfor %}
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
38 {% endmacro %}
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
39
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
40 {% macro int(name, label="", init=0) %}
153
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
41 {{ field("number", name=name, label=label, value=init, step=1, min=0, **kwargs) }}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
42 {% endmacro %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
43
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
44 {% macro checkbox(name, label="", checked=false) %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
45 {% if checked %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
46 {{ field("checkbox", name=name, label=label, checked="checked", **kwargs) }}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
47 {% else %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
48 {{ field("checkbox", name=name, label=label, **kwargs) }}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
49 {% endif %}
52
87680eed9e25 input(field, form): improved classes + new email field
Goffi <goffi@goffi.org>
parents: 46
diff changeset
50 {% endmacro %}
87680eed9e25 input(field, form): improved classes + new email field
Goffi <goffi@goffi.org>
parents: 46
diff changeset
51
87680eed9e25 input(field, form): improved classes + new email field
Goffi <goffi@goffi.org>
parents: 46
diff changeset
52 {% macro text(name, label="", placeholder="", required=false) %}
153
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
53 {{ field("text", name=name, label=label, required=required, placeholder=placeholder, **kwargs) }}
10
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
54 {% endmacro %}
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
55
52
87680eed9e25 input(field, form): improved classes + new email field
Goffi <goffi@goffi.org>
parents: 46
diff changeset
56 {% macro password(name, label="", required=false) %}
153
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
57 {{ field("password", name=name, label=label, required=required, **kwargs) }}
52
87680eed9e25 input(field, form): improved classes + new email field
Goffi <goffi@goffi.org>
parents: 46
diff changeset
58 {% endmacro %}
87680eed9e25 input(field, form): improved classes + new email field
Goffi <goffi@goffi.org>
parents: 46
diff changeset
59
87680eed9e25 input(field, form): improved classes + new email field
Goffi <goffi@goffi.org>
parents: 46
diff changeset
60 {% macro email(name, label="", required=false) %}
153
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
61 {{ field("email", name=name, label=label, required=required, **kwargs) }}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
62 {% endmacro %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
63
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
64 {% macro date(name, label="", required=false) %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
65 {{ field("date", name=name, label=label, required=required, **kwargs) }}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
66 {% endmacro %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
67
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
68 {% macro url(name, label="", required=false) %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
69 {{ field("url", name=name, label=label, required=required, **kwargs) }}
27
38328c57f3ef field: added new text and textarea macros
Goffi <goffi@goffi.org>
parents: 20
diff changeset
70 {% endmacro %}
38328c57f3ef field: added new text and textarea macros
Goffi <goffi@goffi.org>
parents: 20
diff changeset
71
153
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
72 {% macro file(name, label="", required=false) %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
73 {{ field("file", name=name, label=label, required=required, **kwargs) }}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
74 {% endmacro %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
75
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
76 {% macro textarea(name, label="", rows=10, cols=50, placeholder='', required=false) %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
77 <div class="form_input {{kwargs.pop('class', '')}}">
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
78 {% set cur_id = name|next_gidx %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
79 {% if label %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
80 <label for="{{cur_id}}" {{'class="required"'|safe if required}}>{{label}}</label>
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
81 {% endif %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
82 <textarea id="{{cur_id}}" name="{{name}}" rows="{{rows}}" cols="{{cols}}" placeholder="{{placeholder}}" {{"required" if required}} class="{{kwargs.pop('class', '')}}"></textarea>
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
83 </div>
27
38328c57f3ef field: added new text and textarea macros
Goffi <goffi@goffi.org>
parents: 20
diff changeset
84 {% endmacro %}
38328c57f3ef field: added new text and textarea macros
Goffi <goffi@goffi.org>
parents: 20
diff changeset
85
10
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
86 {% macro meta(name, value) %}
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
87 <input type="hidden" name="{{name}}" value="{{value}}">
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
88 {% endmacro %}
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
89
203
bdc578994b97 input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
Goffi <goffi@goffi.org>
parents: 166
diff changeset
90 {% macro submit(text=_("Send"), id=none) %}
bdc578994b97 input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
Goffi <goffi@goffi.org>
parents: 166
diff changeset
91 {# submit button
bdc578994b97 input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
Goffi <goffi@goffi.org>
parents: 166
diff changeset
92
bdc578994b97 input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
Goffi <goffi@goffi.org>
parents: 166
diff changeset
93 @param text(str): label of the button
bdc578994b97 input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
Goffi <goffi@goffi.org>
parents: 166
diff changeset
94 @param id(none, str): id of the element
bdc578994b97 input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
Goffi <goffi@goffi.org>
parents: 166
diff changeset
95 #}
231
aa37750c2617 theme (default): various fixes:
Goffi <goffi@goffi.org>
parents: 203
diff changeset
96 <input {{ 'id="{id}"'.format(id=id)|safe if id }} class="form_submit btn {{kwargs.pop('class', '')}}" type="submit" value="{{text}}">
10
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
97 {% endmacro %}