Mercurial > libervia-backend
diff sat/tools/xml_tools.py @ 2668:c274201cea94
core, frontends (xmlui): added "hidden" widget, to specify a value to be returned unmodified
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 31 Aug 2018 15:57:11 +0200 |
parents | a55a14c3cbf4 |
children | 5c2ed8a5ae22 |
line wrap: on
line diff
--- a/sat/tools/xml_tools.py Fri Aug 31 15:47:00 2018 +0200 +++ b/sat/tools/xml_tools.py Fri Aug 31 15:57:11 2018 +0200 @@ -78,6 +78,8 @@ widget_type = "textbox" widget_args[0] = u"\n".join(field.values) widget_kwargs["read_only"] = read_only + elif field.fieldType == "hidden": + widget_type = "hidden" elif field.fieldType == "text-private": widget_type = "password" widget_kwargs["read_only"] = read_only @@ -148,11 +150,12 @@ widget_type, widget_args, widget_kwargs = widget_filter( form_ui, widget_type, widget_args, widget_kwargs ) - label = field.label or field.var - if label: - form_ui.addLabel(label) - else: - form_ui.addEmpty() + if widget_type != "hidden": + label = field.label or field.var + if label: + form_ui.addLabel(label) + else: + form_ui.addEmpty() form_ui.addWidget(widget_type, *widget_args, **widget_kwargs) @@ -902,7 +905,6 @@ used most of time to display the desciption or name of the next widget """ - type = "label" def __init__(self, xmlui, label, name=None, parent=None): @@ -910,6 +912,22 @@ self.elem.setAttribute("value", label) +class HiddenWidget(Widget): + """Not displayed widget, frontends will just copy the value(s)""" + type = "hidden" + + def __init__(self, xmlui, value, name, parent=None): + super(HiddenWidget, self).__init__(xmlui, name, parent) + value_elt = self.xmlui.doc.createElement("value") + text = self.xmlui.doc.createTextNode(value) + value_elt.appendChild(text) + self.elem.appendChild(value_elt) + + @property + def value(self): + return self.elem.firstChild.firstChild.wholeText + + class JidWidget(Widget): """Used to display a Jabber ID, some specific methods can be added"""