# HG changeset patch # User Goffi # Date 1522307372 -7200 # Node ID 65695b9343d356747699a7a8f7dfd068c3a36805 # Parent 3e03de7691ce318402665f2779b0743af10e0878 jp (xmlui): added whitelist, read_only and values_only options: - whitelist is set on XMLUI creation, it's the same as for other frontends - read_only is set on XMLUI display, it indicates that input are not expected - values_only is set on XMLUI display, it indicates that only values are to be displayed (it implies read_only) diff -r 3e03de7691ce -r 65695b9343d3 frontends/src/jp/xmlui_manager.py --- a/frontends/src/jp/xmlui_manager.py Thu Mar 29 09:03:19 2018 +0200 +++ b/frontends/src/jp/xmlui_manager.py Thu Mar 29 09:09:32 2018 +0200 @@ -235,6 +235,10 @@ # TODO: handle flags, notably multi def show(self): + if self.root.values_only: + for value in self.values: + self.disp(self.value) + return if not self.options: return @@ -243,13 +247,13 @@ for idx, (value, label) in enumerate(self.options): elems = [] - if not self.root.readonly: + if not self.root.read_only: elems.extend([C.A_SUBHEADER, unicode(idx), A.RESET, u': ']) elems.append(label) self.verboseName(elems, value) self.disp(A.color(*elems)) - if self.root.readonly: + if self.root.read_only: return if len(self.options) == 1: @@ -307,6 +311,9 @@ def _xmluiAppend(self, widget): self.children.append(widget) + def _xmluiRemove(self, widget): + self.children.remove(widget) + def show(self): for child in self.children: child.show() @@ -333,7 +340,7 @@ if for_name is not None: for_widget = self.root.widgets[for_name] wid_type = for_widget.type - if wid_type in ('text', 'string', 'jid_input'): + if self.root.values_only or wid_type in ('text', 'string', 'jid_input'): no_lf = True elif wid_type == 'bool' and for_widget.read_only: no_lf = True @@ -386,17 +393,19 @@ class XMLUIPanel(xmlui_manager.XMLUIPanel): widget_factory = WidgetFactory() _actions = 0 # use to keep track of bridge's launchAction calls - readonly = False + read_only = False + values_only = False workflow = None _submit_cb = None - def __init__(self, host, parsed_dom, title=None, flags=None, callback=None, ignore=None, profile=None): + def __init__(self, host, parsed_dom, title=None, flags=None, callback=None, ignore=None, whitelist=None, profile=None): xmlui_manager.XMLUIPanel.__init__(self, host, parsed_dom, title = title, flags = flags, ignore = ignore, + whitelist = whitelist, profile=host.profile) self.submitted = False @@ -404,7 +413,7 @@ def command(self): return self.host.command - def show(self, workflow=None): + def show(self, workflow=None, read_only=False, values_only=False): """display the panel @param workflow(list, None): command to execute if not None @@ -413,7 +422,13 @@ command are a list of consts or lists: - SUBMIT is the only constant so far, it submits the XMLUI - list must contain widget name/widget value to fill + @param read_only(bool): if True, don't request values + @param values_only(bool): if True, only show select values (imply read_only) """ + self.read_only = read_only + self.values_only = values_only + if self.values_only: + self.read_only = True if workflow: XMLUIPanel.workflow = workflow if XMLUIPanel.workflow: @@ -491,7 +506,7 @@ class XMLUIDialog(xmlui_manager.XMLUIDialog): type = 'dialog' dialog_factory = WidgetFactory() - readonly = False + read_only = False def show(self, dummy=None): self.dlg.show() diff -r 3e03de7691ce -r 65695b9343d3 src/plugins/plugin_misc_merge_requests.py --- a/src/plugins/plugin_misc_merge_requests.py Thu Mar 29 09:03:19 2018 +0200 +++ b/src/plugins/plugin_misc_merge_requests.py Thu Mar 29 09:09:32 2018 +0200 @@ -145,6 +145,7 @@ other params are the same as for [TICKETS._get] @return (tuple[list[unicode], list[dict[unicode, unicode]])): tuple with - XMLUI of the tickets, like [TICKETS._get] + - node metadata - list of parsed request data (if extra['parse'] is set, else empty list) """ if not node: diff -r 3e03de7691ce -r 65695b9343d3 src/tools/xml_tools.py --- a/src/tools/xml_tools.py Thu Mar 29 09:03:19 2018 +0200 +++ b/src/tools/xml_tools.py Thu Mar 29 09:09:32 2018 +0200 @@ -1122,7 +1122,7 @@ @param panel_type: one of - C.XMLUI_WINDOW (new window) - C.XMLUI_POPUP - - C.XMLUI_FORM (formulaire, depend of the frontend, usually a panel with cancel/submit buttons) + - C.XMLUI_FORM (form, depend of the frontend, usually a panel with cancel/submit buttons) - C.XMLUI_PARAM (parameters, presentation depend of the frontend) - C.XMLUI_DIALOG (one common dialog, presentation depend of frontend) @param container: disposition of elements, one of: