comparison default/input/xmlui.html @ 71:6f1686723472

input(xmlui): added generate_list method, similar to generate_table but generate list of items instead.
author Goffi <goffi@goffi.org>
date Mon, 04 Dec 2017 00:47:42 +0100
parents 9834106678da
children cc36a5b990ab
comparison
equal deleted inserted replaced
70:90a303a14112 71:6f1686723472
90 </tr> 90 </tr>
91 {% endfor %} 91 {% endfor %}
92 </tbody> 92 </tbody>
93 </table> 93 </table>
94 {% endmacro %} 94 {% endmacro %}
95
96
97
98
99 {% macro generate_list(xmlui_items, fields, formatters, item_class_fields, on_click) %}
100 {# generate a list of rendered XMLUI from requested widgets names
101 very similar to generate_table but generate a list instead of a tabme
102 @param xmlui_items(iterable[unicode]): list of xmlui to show
103 @param fields(tuple[unicode,unicode]): fields to show (name, label)
104 @param formatters(dict): dictionary of templates to format values:
105 field_name => template
106 if no formatter is set (or None is used) for a field, it will be used unmodified.
107 current xmlui items will be set as "item" key
108 @param item_class_fields(iterable[unicode]): name of fields to use as class
109 class will be "{name}_{value}" where name is field name, and value field value
110 all lowercase/stripped
111 @param on_click(data_objects.OnClick): thing to do when clicking on a row
112 #}
113 {% if formatters is undefined %}
114 {% set formatters = {} %}
115 {% endif %}
116 <ul class="xmlui_list">
117 {% for xmlui in xmlui_items %}
118 <li>
119 {% set link=on_click.formatUrl(xmlui.widget_value) if on_click.url else none %}
120 <a {{ {'class': xmlui|xmlui_class(item_class_fields),
121 'href':link}|xmlattr }}>
122 {% for name,label in fields %}
123 <span {{ {'class': 'xmlui_field__'+name}|xmlattr }}>
124 {% for label in xmlui.widgets[name].labels %}
125 <span>{{ label|adv_format(formatters.get(name),item=xmlui.widget_value) }}</span>
126 {% endfor %}
127 </span>
128 {% endfor %}
129 </a>
130 </li>
131 {% endfor %}
132 </ul>
133 {% endmacro %}
134
135
136
137
95 138
96 {# containers #} 139 {# containers #}
97 140
98 {% macro vertical_container(cont, config) %} 141 {% macro vertical_container(cont, config) %}
99 <div class="xmlui_cont xmlui_cont_vertical"> 142 <div class="xmlui_cont xmlui_cont_vertical">