Skip to content
Snippets Groups Projects
Commit 1f5accd1 authored by tux091's avatar tux091
Browse files

Backport the 0.5.x syntax for the GridModifier.

parent b927d41c
No related branches found
No related tags found
No related merge requests found
......@@ -111,7 +111,7 @@ formModifier.configure(buttonAlign='right',
defaults={'height': 320})
#
# Modify the publications grid
# Define a column template for the publications grid
#
tpl = ['<b>{PublicationsTitle}</b><br>',
'{PublicationsAuthors}',
......@@ -139,35 +139,40 @@ tpl = ['<b>{PublicationsTitle}</b><br>',
'<br>Auteurs CPPM : {PublicationsAuthors_cppm}'
]
gridModifier = dbui.GridModifier('publications')
gridModifier.merge_columns('title',
'authors',
'id_collaborations',
'id_publishers',
'doi',
'volume',
'first_page',
'last_page',
'e_print',
'conference_title',
'conference_url',
'conference_start',
'conference_end',
'conference_town',
'id_countries',
'conference_speaker',
'report_numbers',
'id_reports',
'authors_cppm',
autohide=True,
header=T('Publication'),
position=0,
tpl=tpl,
width=700)
#
# Setup a filter panel for the publication grid
#
filters = [('year', '==', T('select publication for a given year')),
('id_teams', '==', T('select publications for a given team')),
('id_projects', '==', T('select publications for a given project')),
('id_categories_aeres', '==', T('select publications with a given AERES code')),
('authors_cppm', 'contains', T('select publications for a given CPPM author')),
]
gm = dbui.GridModifier('publications')
gm.merge_columns('title',
'authors',
'id_collaborations',
'id_publishers',
'doi',
'volume',
'first_page',
'last_page',
'e_print',
'conference_title',
'conference_url',
'conference_start',
'conference_end',
'conference_town',
'id_countries',
'conference_speaker',
'report_numbers',
'id_reports',
'authors_cppm',
autohide=True,
position=0,
extjs={'header': T('Publication'), 'tpl': tpl, 'width': 700})
gm.set_filters(*filters, extjs={'width': 300})
('authors_cppm', 'contains', T('select publications for a given CPPM author'))]
gridModifier.set_filters(*filters,
width=300)
......@@ -362,7 +362,7 @@ class CfgSvc(BaseSvc):
di['items'].append(cfg)
# user configuration options for Ext.form;FieldSet
# user configuration options for Ext.form.FieldSet
di.update(grid_filters.extjs)
return di
......
......@@ -12,7 +12,6 @@ from modifier import Modifier
GRID_MODIFIERS = 'grid_modifiers'
MSG_EXTJS_MISSING = 'keyword argument extjs is missing'
MSG_HEADER_MISSING = 'configuration option header is missing in extjs'
MSG_INVALID_KEYWORD = 'invalid keyword %s'
MSG_POSITION_MISSING = 'keyword argument position is missing'
......@@ -115,27 +114,23 @@ class GridModifier(Modifier):
of the underlying Ext.grid.TemplateColumn
"""
keywords = ['autohide', 'extjs', 'position']
for el in keywords:
if el not in keywords:
raise GridModifierException(MSG_INVALID_KEYWORD % el)
keywords = ['autohide', 'position']
extjs = dict(kwargs)
for key in keywords:
if key in extjs:
del extjs[key]
if 'position' not in kwargs:
raise GridModifierException(MSG_POSITION_MISSING)
if 'extjs' not in kwargs:
raise GridModifierException(MSG_EXTJS_MISSING)
if 'header' not in kwargs['extjs']:
if 'header' not in kwargs:
raise GridModifierException(MSG_HEADER_MISSING)
if 'tpl' not in kwargs['extjs']:
if 'tpl' not in kwargs:
raise GridModifierException(MSG_TPL_MISSING)
di = Storage(extjs=kwargs['extjs'],
position=kwargs['position'])
di = Storage(extjs=extjs, position=kwargs['position'])
self.data.template_columns.append(di)
if 'autohide' in kwargs and kwargs['autohide']:
......@@ -154,11 +149,9 @@ class GridModifier(Modifier):
the method dbsvc._encode_query
- a string with a comment for the tool tip
The keyword argument extjs is a dictionary containing
the configuration options of the underlying Ext.form.FieldSet.
The keyword argument contains the configuration options for the
underlying Ext.form.FieldSet. For more information see the ExtJS
documentation.
"""
if 'extjs' not in kwargs:
kwargs['extjs'] = {}
self.data.grid_filters = Storage(filters=filters, extjs=kwargs['extjs'])
self.data.grid_filters = Storage(filters=filters, extjs=kwargs)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment