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

Backport the 0.5.x syntax for FieldsModifier

parent d72c5fe7
No related branches found
No related tags found
No related merge requests found
...@@ -37,16 +37,19 @@ dbui.configure_grids(db, plugins=['pGridRowEditor', ...@@ -37,16 +37,19 @@ dbui.configure_grids(db, plugins=['pGridRowEditor',
# #
# Create composite fields for the publication form # Create composite fields for the publication form
# #
fm = dbui.FieldModifier('publications') fieldsModifier = dbui.FieldsModifier('publications')
fm.configure_field('year', maxValue=datetime.now().year) fieldsModifier.configure_field('year',
maxValue=datetime.now().year)
fm.merge_fields('first_page',
'last_page', fieldsModifier.merge_fields('first_page',
extjs={'fieldLabel': T('Pages'), 'defaults': {'flex': 1}}) 'last_page',
fieldLabel=T('Pages'),
fm.merge_fields('conference_start', defaults={'flex': 1})
'conference_end',
extjs={'fieldLabel': T('Dates'), 'defaults': {'flex': 1}}) fieldsModifier.merge_fields('conference_start',
'conference_end',
fieldLabel=T('Dates'),
defaults={'flex': 1})
# #
# Create fieldSet for the publication form # Create fieldSet for the publication form
......
...@@ -64,6 +64,8 @@ class CfgSvc(BaseSvc): ...@@ -64,6 +64,8 @@ class CfgSvc(BaseSvc):
See the documentation of the Ext.form.Compositefield class for details. See the documentation of the Ext.form.Compositefield class for details.
""" """
# handle composite field and fieldsets
field_modifiers = self.environment['plugins'].dbui.field_modifiers field_modifiers = self.environment['plugins'].dbui.field_modifiers
if tablename in field_modifiers: if tablename in field_modifiers:
field_modifier = field_modifiers[tablename] field_modifier = field_modifiers[tablename]
...@@ -74,6 +76,7 @@ class CfgSvc(BaseSvc): ...@@ -74,6 +76,7 @@ class CfgSvc(BaseSvc):
elif fieldname not in field_modifier.composite_fields.others: elif fieldname not in field_modifier.composite_fields.others:
li.append(self._get_form_field(tablename, fieldname)) li.append(self._get_form_field(tablename, fieldname))
# handle basic field
else: else:
li.append(self._get_form_field(tablename, fieldname)) li.append(self._get_form_field(tablename, fieldname))
......
...@@ -62,24 +62,19 @@ class FieldsModifier(Modifier): ...@@ -62,24 +62,19 @@ class FieldsModifier(Modifier):
Each field is identified by its database field name. Each field is identified by its database field name.
The keyword argument ExtJS contains the configuration options of The keyword arguments contains the configuration options of
the Ext.form.CompositeField widget. the Ext.form.CompositeField widget.
""" """
extjs = {}
if 'extjs' in kwargs:
extjs.update(kwargs['extjs'])
# define the main field as the first field in the list
main_field = fields[0] main_field = fields[0]
other_fields = fields[1:] other_fields = fields[1:]
# NOTE
# In order to simplify the processing keep a list of # In order to simplify the processing keep a list of
# the main field, the first field appearing in the composite field, # the main field and a list of the other fields.
# and a list of the other fields.
self.data.composite_fields.main.append(main_field) self.data.composite_fields.main.append(main_field)
self.data.composite_fields.others.extend(other_fields) self.data.composite_fields.others.extend(other_fields)
di = Storage(fields=fields, extjs=extjs) di = Storage(fields=fields, extjs=kwargs)
self.data.composite_fields[main_field] = di self.data.composite_fields[main_field] = di
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