Mercurial > libervia-templates
annotate default/input/xmlui.html @ 58:4347910cc594
input(xmlui): added attributes argument to create:
specific attributes can be used of named widget (for some widget converted to <input> only so far).
The argument is a dict from widget name to a sub dict containing the keyword arguments.
The next dict_ext filter is used.
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 09 Nov 2017 08:05:23 +0100 |
parents | d58fdd57df49 |
children | dd15b6c0b1d3 |
rev | line source |
---|---|
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 {% import 'input/field.html' as field %} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 {# generate methods #} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
5 {% macro generate_container(cont, config) %} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 {% if cont.type == 'vertical' %} |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
7 {{ vertical_container(cont, config) }} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 {% elif cont.type == 'pairs' %} |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
9 {{ pairs_container(cont, config) }} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 {% elif cont.type == 'label' %} |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
11 {{ label_container(cont, config) }} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 {% endif %} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 {% endmacro %} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
15 {% macro generate_widget(wid, config, id=none) %} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 {% if wid.type == 'text' %} |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
17 {{ text_widget(wid, config, id=id) }} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 {% elif wid.type == 'label' %} |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
19 {{ label_widget(wid, config) }} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 {% elif wid.type == 'string' %} |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
21 {{ string_widget(wid, config, id=id) }} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 {% elif wid.type == 'textbox' %} |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
23 {{ textbox_widget(wid, config, id=id) }} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 {% elif wid.type == 'list' %} |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
25 {{ list_widget(wid, config, id=id) }} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 {% endif %} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 {% endmacro %} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
29 {% macro generate_children(cont, config) %} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 {% for child in cont.children %} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 {% if child.category == 'container' %} |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
32 {{ generate_container(child, config) }} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 {% else %} |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
34 {{ generate_widget(child, config) }} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 {% endif %} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 {% endfor %} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 {% endmacro %} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 |
58
4347910cc594
input(xmlui): added attributes argument to create:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
40 {% macro generate(xmlui, form=true, filters=none, attributes=none) %} |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
41 {# generate HTML from XMLUI |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
42 @param xmlui(template_xmlui.XMLUIPanel): xmlui to use |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
43 @param form(bool): if true will generate form elements |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
44 @param filters(dict,none): filters as expected by item_filter |
58
4347910cc594
input(xmlui): added attributes argument to create:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
45 @param attributes(dict,none): extra attributes to put on named widgets |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
46 #} |
58
4347910cc594
input(xmlui): added attributes argument to create:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
47 {% set config = {'form':form, 'filters':filters or {}, 'attrs': attributes or {}} %} |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
48 {{ generate_container(xmlui.main_cont, config) }} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
49 {% endmacro %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
50 |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
51 {% macro generate_table(xmlui_items, fields, formatters, tr_class_fields, on_click) %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
52 {# generate a HTML table from requested widgets names |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
53 @param xmlui_items(iterable[unicode]): list of xmlui to show (one per row) |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
54 @param fields(tuple[unicode,unicode]): fields to show (name, label) |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
55 @param formatters(dict): dictionary of templates to format values: |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
56 field_name => template |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
57 if no formatter is set (or None is used) for a field, it will be used unmodified. |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
58 current xmlui items will be set as "item" key |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
59 @param tr_class_fields(iterable[unicode]): name of fields to use as class |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
60 class will be "{name}_{value}" where name is field name, and value field value |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
61 all lowercase/stripped |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
62 @param on_click(data_objects.OnClick): thing to do when clicking on a row |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
63 #} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
64 {% if formatters is undefined %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
65 {% set formatters = {} %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
66 {% endif %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
67 <table> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
68 <thead> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
69 <tr> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
70 {% for name,label in fields %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
71 <th>{{ label }}</th> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
72 {% endfor %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
73 </tr> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
74 </thead> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
75 <tbody> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
76 {% for xmlui in xmlui_items %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
77 {% set link=on_click.formatUrl(xmlui.widget_value) if on_click.url else none %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
78 <tr {{ {'class': xmlui|xmlui_class(tr_class_fields)}|xmlattr }}> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
79 |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
80 {% for name,label in fields %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
81 <td {{ {'class': 'td_'+name}|xmlattr }}> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
82 {% for value in xmlui.widgets[name].values %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
83 <a {{ {'href':link}|xmlattr }}>{{ value|adv_format(formatters.get(name),item=xmlui.widget_value) }}</a> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
84 {% endfor %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
85 </td> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
86 {% endfor %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
87 </tr> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
88 {% endfor %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
89 </tbody> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
90 </table> |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
91 {% endmacro %} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
92 |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
93 {# containers #} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
94 |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
95 {% macro vertical_container(cont, config) %} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
96 <div class="xmlui_cont xmlui_cont_vertical"> |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
97 {{ generate_children(cont, config) }} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
98 </div> |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
99 {% endmacro %} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
100 |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
101 {% macro pairs_container(cont, config) %} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 {# TODO: proper impelmentation (do the same as vertical container for now #} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
103 <div class="xmlui_cont xmlui_cont_vertical"> |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
104 {{ generate_children(cont, config) }} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
105 </div> |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
106 {% endmacro %} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
107 |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
108 {% macro label_container(cont, config) %} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
109 <div class="xmlui_cont xmlui_cont_vertical"> |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 {% for child in cont.children %} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
111 {% if loop.index is odd %} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 {# label #} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 {% if child.type == 'label' %} |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
114 {% set for_ = ('wid_' + (child.for_name or child.name or '_noname'))|next_gidx %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
115 {{ label_widget(child, config, for=for_) }} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 {% endif %} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
117 {% else %} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 {# widget #} |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
119 {% set id = ('wid_' + (child.name or '_noname'))|cur_gidx %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
120 {{ generate_widget(child, config, id=id) }} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 {% endif %} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 {% endfor %} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 </div> |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 {% endmacro %} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
125 |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 {# widgets #} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
129 {% macro text_widget(wid, config, id=none) %} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
130 <p class="xmlui_widget xmlui_text" {{ {'id':id}|xmlattr }}> |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
131 {{- wid|item_filter(config.filters)|default('\u00A0',true) -}} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 </p> |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
133 {% endmacro%} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
135 {% macro label_widget(wid, config, for=none) %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
136 {% if config.form %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
137 <label class="xmlui_widget xmlui_label" {{ {'for':for}|xmlattr }}> |
55
d58fdd57df49
input/xmlui: fixed for_name in labels + selection in listWidget
Goffi <goffi@goffi.org>
parents:
53
diff
changeset
|
138 {{wid|item_filter(config.filters)}} |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
139 </label> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
140 {% else %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
141 <span class="xmlui_widget xmlui_label" {{ {'id':none if not for else 'label_%s'|format(for)}|xmlattr }}>{{wid|item_filter(config.filters)}}</span> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
142 {% endif %} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
143 {% endmacro%} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
144 |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
145 {% macro string_widget(wid, config, id=none) %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
146 {% if config.form %} |
58
4347910cc594
input(xmlui): added attributes argument to create:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
147 <input class="xmlui_widget xmlui_string" type="text" {{ {'name':wid.name, 'id':id, 'value':wid|item_filter(config.filters)}|dict_ext(config.attrs, wid.name)|xmlattr }}> |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
148 {% else %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
149 <div class="xmlui_widget xmlui_string" {{ {'id':id}|xmlattr }}> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
150 {{- wid|item_filter(config.filters)|default('\u00A0',true) -}} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
151 </div> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
152 {% endif %} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
153 {% endmacro%} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
154 |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
155 {% macro textbox_widget(wid, config, id=none) %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
156 {% if config.form %} |
58
4347910cc594
input(xmlui): added attributes argument to create:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
157 <textarea class="xmlui_widget xmlui_textbox" rows="10" cols="50" {{ {'name':wid.name, 'id':id}|dict_ext(config.attrs, wid.name)|xmlattr }}> |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
158 {{- wid|item_filter(config.filters) -}} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
159 </textarea> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
160 {% else %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
161 <p class="xmlui_widget xmlui_textbox" {{ {'id':id}|xmlattr }}> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
162 {{- wid|item_filter(config.filters) -}} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
163 </p> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
164 {% endif %} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
165 {% endmacro%} |
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
166 |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
167 {% macro list_widget(wid, config, id=none) %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
168 {% if config.form %} |
58
4347910cc594
input(xmlui): added attributes argument to create:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
169 <select class="xmlui_widget xmlui_list" {{ {'name':wid.name, 'id':id}|dict_ext(config.attrs, wid.name)|xmlattr }}> |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
170 {% for value,label in wid.options %} |
55
d58fdd57df49
input/xmlui: fixed for_name in labels + selection in listWidget
Goffi <goffi@goffi.org>
parents:
53
diff
changeset
|
171 <option {{ {'value':value}|xmlattr }} {{ 'selected' if value in wid.selected }}> |
53
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
172 {{- label -}} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
173 </option> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
174 {% endfor %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
175 </select> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
176 {% else %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
177 <div class="xmlui_widget xmlui_list" {{ {'id':id}|xmlattr }}> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
178 {% for value,label in wid.items %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
179 <span class="xmlui_list_item value_{{value|attr_escape}}"> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
180 {{- label -}} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
181 </span> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
182 {% endfor %} |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
183 </div> |
dfef430a26ef
input(xmlui): added a macro to generate a table from list of XMLUI items + many improvments in item generation (see docstrings)
Goffi <goffi@goffi.org>
parents:
47
diff
changeset
|
184 {% endif %} |
47
7d5cca978eeb
input/xmlui: XMLUI generation first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
185 {% endmacro%} |