Commit 90312aea authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Refactor the selector for report in order to use a accordion layout.

parent 87ddde6b
...@@ -111,6 +111,7 @@ ...@@ -111,6 +111,7 @@
'Error...': 'Erreur...', 'Error...': 'Erreur...',
'Event': 'Evènement', 'Event': 'Evènement',
'Event category': 'Event category', 'Event category': 'Event category',
'Event data': "Donée d'un évènement",
'Events': 'Evènements', 'Events': 'Evènements',
'events': 'évènements', 'events': 'évènements',
'Evènement': 'Evènement', 'Evènement': 'Evènement',
......
...@@ -5,17 +5,17 @@ ...@@ -5,17 +5,17 @@
tp_data = T("The field history.data contains the given value.") tp_data = T("The field history.data contains the given value.")
virtdb.define_table('selector', virtdb.define_table('selector',
Field('year_start', 'integer', default=year), Field('year_start', 'integer', default=year, label="Start"),
Field('year_end', 'integer'), Field('year_end', 'integer', label="End"),
Field('id_domains', 'reference domains', label=T('Domain')), Field('id_domains', 'reference domains', label='Domain'),
Field('id_teams', 'reference teams', label=T('Team')), Field('id_teams', 'reference teams', label='Team'),
Field('id_projects', 'reference projects', label=T('Project')), Field('id_projects', 'reference projects', label='Project'),
Field('id_fundings', 'reference fundings', label=T('Funding')), Field('id_fundings', 'reference fundings', label=''),
Field('id_people_categories', 'reference alias_people_categories', label= T("People category")), Field('id_people_categories', 'reference alias_people_categories', label= 'Category'),
Field('id_people_code', 'reference people_categories', label= T("People quality")), Field('id_people_code', 'reference people_categories', label= 'Quality'),
Field('id_object_categories', 'reference alias_object_categories', label= T("Object category")), Field('id_object_categories', 'reference alias_object_categories', label= 'Category'),
Field('id_object_code', 'reference object_categories', label= T("Object code")), Field('id_object_code', 'reference object_categories', label= 'Code'),
Field('data', 'string', comment=tp_data, label= T("Data"))) Field('data', 'string', comment=tp_data, label= ''))
virtdb.selector.id_object_categories.requires = \ virtdb.selector.id_object_categories.requires = \
IS_IN_DB(db, 'alias_object_categories.category') IS_IN_DB(db, 'alias_object_categories.category')
...@@ -34,15 +34,15 @@ virtdb.selector.id_fundings.requires = IS_IN_DB(db, 'fundings.agency') ...@@ -34,15 +34,15 @@ virtdb.selector.id_fundings.requires = IS_IN_DB(db, 'fundings.agency')
virtdb.selector.id_projects.requires = IS_IN_DB(db, 'projects.project') virtdb.selector.id_projects.requires = IS_IN_DB(db, 'projects.project')
virtdb.selector.id_teams.requires = IS_IN_DB(db, 'teams.team') virtdb.selector.id_teams.requires = IS_IN_DB(db, 'teams.team')
#------------------------------------------------------------------------------- # ............................................................................
# #
# FIELDS CONFIGURATiON # FIELDS CONFIGURATiON
# #
#-------------------------------------------------------------------------------
fieldsModifier = dbui.FieldsModifier('selector') fieldsModifier = dbui.FieldsModifier('selector')
fieldsModifier.configure_field('year_start', flex=1) # fieldsModifier.configure_field('year_start', flex=1)
fieldsModifier.configure_field('year_end', flex=1) # fieldsModifier.configure_field('year_end', flex=1)
fieldsModifier.merge_fields('year_start', 'year_end', fieldLabel=T('Period')) # fieldsModifier.merge_fields('year_start', 'year_end', fieldLabel=T('Period'))
mytype = 'xcomboboxuserreset' mytype = 'xcomboboxuserreset'
text = T('select...') text = T('select...')
...@@ -57,8 +57,83 @@ fieldsModifier.configure_field('id_people_code', emptyText=text, xtype=mytype) ...@@ -57,8 +57,83 @@ fieldsModifier.configure_field('id_people_code', emptyText=text, xtype=mytype)
fieldsModifier.configure_field('id_teams', emptyText=text, xtype=mytype) fieldsModifier.configure_field('id_teams', emptyText=text, xtype=mytype)
fieldsModifier.configure_field('id_projects', emptyText=text, xtype=mytype) fieldsModifier.configure_field('id_projects', emptyText=text, xtype=mytype)
#------------------------------------------------------------------------------- fieldsModifier.configure_field(
'data',
header=[T("key"), T("value")],
numColumns=2,
numRows=3,
xtype='xtablefield')
# ............................................................................
# #
# FORM CONFIGURATiON # PANELWITHURLSELECTOR
# - configure it once since it is used many times (lists, metric1D, ...)
# - organise fields within an accordion layout
# #
#-------------------------------------------------------------------------------
# map between field name and field configuration
# keys are the field name or field label for merge fields
mapfields = Storage()
for cfgfield in dbui.to_fields(virtdb.selector):
key = (cfgfield.name if cfgfield.name else cfgfield.fieldLabel)
mapfields[key] = cfgfield
# Organise fields within different panels
# and replace field name by their configuration
items = [
{
'title': T('Period'),
'items': ['SelectorYear_start',
'SelectorYear_end']
}, {
'title': T('Metadata'),
'items': ['SelectorId_domains',
'SelectorId_teams',
'SelectorId_projects']
}, {
'title': T('People'),
'collapsed': True,
'items': ['SelectorId_people_categories',
'SelectorId_people_code']
}, {
'title': T('Object'),
'collapsed': True,
'items': ['SelectorId_object_categories',
'SelectorId_object_code']
}, {
'title': T('Event data'),
'collapsed': True,
'layout': 'fit',
'items': ['SelectorData']
}, {
'title': T('Fundings'),
'collapsed': True,
'layout': 'fit',
'items': ['SelectorId_fundings']
}
]
for panel in items:
panelitems = panel["items"]
for i in xrange(len(panelitems)):
panelitems[i] = mapfields[panelitems[i]]
# configure the accordion layout
# several panel can be open at the same time (multi)
layout = dict(
multi=True,
titleCollapse=True,
type="accordion")
# wrap fields within a FieldSet
fieldset = dbui.FieldSet(
defaults=dict(frame=True),
items=items,
layout=layout,
plugins=["pFormToolTip"],
title=T("Select"))
# configure the PanelWithUrlSelector
selector_panel = dbui.PanelWithUrlSelector(
baseUrl=URL('report', 'grid'),
selectorItems=fieldset)
...@@ -10,11 +10,11 @@ Node = dbui.Node ...@@ -10,11 +10,11 @@ Node = dbui.Node
Panel = dbui.Panel Panel = dbui.Panel
PanelWithUrlSelector = dbui.to_panelWithUrlSelector PanelWithUrlSelector = dbui.to_panelWithUrlSelector
#------------------------------------------------------------------------------- # ............................................................................
# #
# CAS # CAS
# #
#-------------------------------------------------------------------------------
casNode = None casNode = None
if "auth" in globals(): if "auth" in globals():
...@@ -24,11 +24,11 @@ if "auth" in globals(): ...@@ -24,11 +24,11 @@ if "auth" in globals():
casNode.add_child(T('groups'), to_grid('auth_group')) casNode.add_child(T('groups'), to_grid('auth_group'))
casNode.add_child(T('relation user / groups'), to_grid('auth_membership')) casNode.add_child(T('relation user / groups'), to_grid('auth_membership'))
#------------------------------------------------------------------------------- # ............................................................................
# #
# HELP NODE # HELP NODE
# #
#-------------------------------------------------------------------------------
loader = dict(autoLoad=True, loader = dict(autoLoad=True,
renderer='html', renderer='html',
url=URL('plugin_dbui', 'about')) url=URL('plugin_dbui', 'about'))
...@@ -61,22 +61,22 @@ helpNode.add_child(T('documentations'), docLeaf) ...@@ -61,22 +61,22 @@ helpNode.add_child(T('documentations'), docLeaf)
helpNode.add_child(T('versions'), versionLeaf) helpNode.add_child(T('versions'), versionLeaf)
helpNode.sort_children() helpNode.sort_children()
#------------------------------------------------------------------------------- # ............................................................................
# #
# CONFIGURE # CONFIGURE
# #
#-------------------------------------------------------------------------------
cfgNode = Node(T('Configure')) cfgNode = Node(T('Configure'))
cfgNode.add_child(T('the lists'), to_grid('lists')) cfgNode.add_child(T('the lists'), to_grid('lists'))
cfgNode.add_child(T('the metrics 1d'), to_grid('metrics1d')) cfgNode.add_child(T('the metrics 1d'), to_grid('metrics1d'))
cfgNode.add_child(T('the metrics 2d'), to_grid('metrics2d')) cfgNode.add_child(T('the metrics 2d'), to_grid('metrics2d'))
cfgNode.add_child(T('the graphs'), to_grid('graphs')) cfgNode.add_child(T('the graphs'), to_grid('graphs'))
#------------------------------------------------------------------------------- # ............................................................................
# #
# META DATA # META DATA
# #
#-------------------------------------------------------------------------------
metaNode = Node(T('Metadata')) metaNode = Node(T('Metadata'))
metaNode.add_child(T('domains'), to_grid('domains')) metaNode.add_child(T('domains'), to_grid('domains'))
metaNode.add_child(T('fundings'), to_grid('fundings')) metaNode.add_child(T('fundings'), to_grid('fundings'))
...@@ -84,11 +84,11 @@ metaNode.add_child(T('teams'), to_grid('teams')) ...@@ -84,11 +84,11 @@ metaNode.add_child(T('teams'), to_grid('teams'))
metaNode.add_child(T('projects'), to_grid('projects')) metaNode.add_child(T('projects'), to_grid('projects'))
metaNode.sort_children() metaNode.sort_children()
#------------------------------------------------------------------------------- # ............................................................................
# #
# PEOPLE & OBJECT # PEOPLE & OBJECT
# #
#-------------------------------------------------------------------------------
objectNode = Node(T('People and objects')) objectNode = Node(T('People and objects'))
objectNode.add_child(T('people'), to_grid('people')) objectNode.add_child(T('people'), to_grid('people'))
objectNode.add_child(T('people_categories'), to_grid('people_categories')) objectNode.add_child(T('people_categories'), to_grid('people_categories'))
...@@ -96,85 +96,85 @@ objectNode.add_child(T('objects'), to_grid('objects')) ...@@ -96,85 +96,85 @@ objectNode.add_child(T('objects'), to_grid('objects'))
objectNode.add_child(T('object_categories'), to_grid('object_categories')) objectNode.add_child(T('object_categories'), to_grid('object_categories'))
objectNode.sort_children() objectNode.sort_children()
#------------------------------------------------------------------------------- # ............................................................................
# #
# EVENT # EVENT
# #
#-------------------------------------------------------------------------------
eventNode = Node(T('Events')) eventNode = Node(T('Events'))
eventNode.add_child(T('definitions'), to_grid('events')) eventNode.add_child(T('definitions'), to_grid('events'))
eventNode.add_child(T('history'), to_grid('history')) eventNode.add_child(T('history'), to_grid('history'))
#------------------------------------------------------------------------------- # ............................................................................
# #
# LIST # LIST
# #
#-------------------------------------------------------------------------------
listNode = Node(T('The lists')) listNode = Node(T('The lists'))
for row in db(db.lists.id > 0).select(orderby=db.lists.name): for row in db(db.lists.id > 0).select(orderby=db.lists.name):
leaf = PanelWithUrlSelector(virtdb.selector, leaf = selector_panel
baseUrl=URL('report', 'grid'), leaf.baseUrl = URL('report', 'grid')
baseParams={'id_lists': row.id}) leaf.baseParams = {'id_lists': row.id}
listNode.add_child(row.name, leaf) listNode.add_child(row.name, leaf)
#------------------------------------------------------------------------------- # ............................................................................
# #
# METRIC 1D # METRIC 1D
# #
#-------------------------------------------------------------------------------
metric1dNode = Node(T('The metrics 1d')) metric1dNode = Node(T('The metrics 1d'))
for row in db(db.metrics1d.id > 0).select(orderby=db.metrics1d.name): for row in db(db.metrics1d.id > 0).select(orderby=db.metrics1d.name):
leaf = PanelWithUrlSelector(virtdb.selector, leaf = selector_panel
baseUrl=URL('report', 'grid'), leaf.baseUrl = URL('report', 'grid')
baseParams={'id_metrics1d': row.id}) leaf.baseParams = {'id_metrics1d': row.id}
metric1dNode.add_child(row.name, leaf) metric1dNode.add_child(row.name, leaf)
metric1dNode.sort_children() metric1dNode.sort_children()
#------------------------------------------------------------------------------- # ............................................................................
# #
# METRIC 2D # METRIC 2D
# #
#-------------------------------------------------------------------------------
metric2dNode = Node(T('The metrics 2d')) metric2dNode = Node(T('The metrics 2d'))
for row in db(db.metrics2d.id > 0).select(orderby=db.metrics2d.name): for row in db(db.metrics2d.id > 0).select(orderby=db.metrics2d.name):
leaf = PanelWithUrlSelector(virtdb.selector, leaf = selector_panel
baseUrl=URL('report', 'grid'), leaf.baseUrl = URL('report', 'grid')
baseParams={'id_metrics2d': row.id}) leaf.baseParams = {'id_metrics2d': row.id}
metric2dNode.add_child(row.name, leaf) metric2dNode.add_child(row.name, leaf)
metric2dNode.sort_children() metric2dNode.sort_children()
#------------------------------------------------------------------------------- # ............................................................................
# #
# GRAPH # GRAPH
# Define by the 2D metrics # Define by the 2D metrics
# #
#-------------------------------------------------------------------------------
graphNode = Node(T('The graphs')) graphNode = Node(T('The graphs'))
for row in db(db.graphs.id > 0).select(orderby=db.graphs.name): for row in db(db.graphs.id > 0).select(orderby=db.graphs.name):
leaf = PanelWithUrlSelector(virtdb.selector, leaf = selector_panel
baseUrl=URL('report', 'graph_mpl'), leaf.baseUrl = URL('report', 'graph_mpl')
baseParams={'id_graphs': row.id}) leaf.baseParams = {'id_graphs': row.id}
graphNode.add_child(row.name, leaf) graphNode.add_child(row.name, leaf)
#------------------------------------------------------------------------------- # ............................................................................
# #
# VIEWPORT # VIEWPORT
# #
#-------------------------------------------------------------------------------
nodes = [helpNode, nodes = [helpNode,
casNode, casNode,
cfgNode, cfgNode,
......
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