Mercurial > libervia-templates
changeset 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 | 90a303a14112 |
children | 18d00a8afc4d |
files | default/input/xmlui.html |
diffstat | 1 files changed, 43 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/default/input/xmlui.html Mon Dec 04 00:46:43 2017 +0100 +++ b/default/input/xmlui.html Mon Dec 04 00:47:42 2017 +0100 @@ -93,6 +93,49 @@ </table> {% endmacro %} + + + +{% macro generate_list(xmlui_items, fields, formatters, item_class_fields, on_click) %} +{# generate a list of rendered XMLUI from requested widgets names + very similar to generate_table but generate a list instead of a tabme + @param xmlui_items(iterable[unicode]): list of xmlui to show + @param fields(tuple[unicode,unicode]): fields to show (name, label) + @param formatters(dict): dictionary of templates to format values: + field_name => template + if no formatter is set (or None is used) for a field, it will be used unmodified. + current xmlui items will be set as "item" key + @param item_class_fields(iterable[unicode]): name of fields to use as class + class will be "{name}_{value}" where name is field name, and value field value + all lowercase/stripped + @param on_click(data_objects.OnClick): thing to do when clicking on a row +#} + {% if formatters is undefined %} + {% set formatters = {} %} + {% endif %} + <ul class="xmlui_list"> + {% for xmlui in xmlui_items %} + <li> + {% set link=on_click.formatUrl(xmlui.widget_value) if on_click.url else none %} + <a {{ {'class': xmlui|xmlui_class(item_class_fields), + 'href':link}|xmlattr }}> + {% for name,label in fields %} + <span {{ {'class': 'xmlui_field__'+name}|xmlattr }}> + {% for label in xmlui.widgets[name].labels %} + <span>{{ label|adv_format(formatters.get(name),item=xmlui.widget_value) }}</span> + {% endfor %} + </span> + {% endfor %} + </a> + </li> + {% endfor %} + </ul> +{% endmacro %} + + + + + {# containers #} {% macro vertical_container(cont, config) %}