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)
This commit is contained in:
parent
25e6a8748d
commit
5fbe44e849
3 changed files with 24 additions and 8 deletions
|
|
@ -235,6 +235,10 @@ class ListWidget(xmlui_manager.ListWidget, OptionsWidget):
|
|||
# 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 @@ class ListWidget(xmlui_manager.ListWidget, OptionsWidget):
|
|||
|
||||
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 @@ class Container(Base):
|
|||
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 @@ class LabelContainer(xmlui_manager.PairsContainer, Container):
|
|||
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 WidgetFactory(object):
|
|||
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 @@ class XMLUIPanel(xmlui_manager.XMLUIPanel):
|
|||
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 @@ class XMLUIPanel(xmlui_manager.XMLUIPanel):
|
|||
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 XMLUIPanel(xmlui_manager.XMLUIPanel):
|
|||
class XMLUIDialog(xmlui_manager.XMLUIDialog):
|
||||
type = 'dialog'
|
||||
dialog_factory = WidgetFactory()
|
||||
readonly = False
|
||||
read_only = False
|
||||
|
||||
def show(self, dummy=None):
|
||||
self.dlg.show()
|
||||
|
|
|
|||
|
|
@ -145,6 +145,7 @@ class MergeRequests(object):
|
|||
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:
|
||||
|
|
|
|||
|
|
@ -1122,7 +1122,7 @@ class XMLUI(object):
|
|||
@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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue