Commit e178e488 authored by Renaud Le Gac's avatar Renaud Le Gac
Browse files

Add the possibility to define individual configurator in Node.

parent c77a6108
......@@ -26,6 +26,10 @@
'Id': 'Id',
'Last Page': 'Dernière Page',
'Max Records': 'Max Records',
'My Date': 'My Date',
'My Int': 'My Int',
'My List': 'My List',
'My String': 'My String',
'Pages': 'Pages',
'Project': 'Projet',
'Projects': 'Projets',
......@@ -57,6 +61,7 @@
'publications': 'publications',
'publishers': 'éditeur',
'report_1': 'report_1',
'report_2': 'report_2',
'reports': 'rapports',
'select publication for a given year': 'selectionne les publication pour une année',
'select publications for a given CPPM author': 'selectionne les publications pour un auteur du CPPM',
......
......@@ -185,8 +185,10 @@ formNode = dbui.Node(T('Forms'), db.tables, cfgSvc.get_form)
gridNode = dbui.Node(T('Tables'), db.tables, cfgSvc.get_grid)
reportNode = dbui.Node(T('Reports'),
{'report_1': URL(c="reports", f="report_1")},
dbui.cfg_configurable_url_panel)
{'report_1': URL(c="reports", f="report_1"),
'report_2': URL(c="reports", f="report_1")},
dbui.cfg_url_panel,
configurators={'report_2': dbui.cfg_configurable_url_panel})
viewportModifier = dbui.ViewportModifier()
viewportModifier.add_node(formNode, gridNode, reportNode)
......
......@@ -70,8 +70,9 @@ class Node(object):
target widget. It is a function getting the leave names, its
attributes (dictionary value) and returning a dictionary.
Dedicated configurator can be setup for each node if needed.
"""
def __init__(self, text, leaves, configurator, hidden=[]):
def __init__(self, text, leaves, configurator, configurators={}, hidden=[]):
"""Constructor of the node
text
......@@ -82,11 +83,16 @@ class Node(object):
will be used as leaf names
configurator
The default configurator apply to all leaves.
Reference to a function accepting either a leave name
or a leave name and the dictionary value. The function
return the configuration dictionary for the ExtJS widget.
The function defines the type of widget.
configurators
A dictionary with references to configurator.
It can be used to associate a different configurator to
each leaf. The key is the leaf name.
hidden
List of leaves to be hidden. It contains leaves names
......@@ -111,15 +117,19 @@ class Node(object):
leaf = cvt[tr_leaf]
if leaf in hidden:
continue
func = configurator
if leaf in configurators:
func = configurators[leaf]
if isinstance(leaves, (list, tuple)):
self.add_children(tr_leaf, configurator(leaf))
self._add_children(tr_leaf, func(leaf))
elif isinstance(leaves, dict):
self.add_children(tr_leaf, configurator(leaf, leaves[leaf]))
self._add_children(tr_leaf, func(leaf, leaves[leaf]))
def add_children(self, text, cfg):
def _add_children(self, text, cfg):
""" Add a child (leaf) to the node.
text
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment