From cfc5cffe0877383cce5b18e7b3760c1f1aaea8a2 Mon Sep 17 00:00:00 2001
From: tux091 <renaud.legac@free.fr>
Date: Wed, 28 Sep 2011 20:09:42 +0200
Subject: [PATCH] Backport the 0.5.x syntax for FieldsModifier

---
 models/db_widgets.py                  | 23 +++++++++++++----------
 modules/plugin_dbui/cfgsvc.py         |  3 +++
 modules/plugin_dbui/fieldsmodifier.py | 13 ++++---------
 3 files changed, 20 insertions(+), 19 deletions(-)
 mode change 100644 => 100755 models/db_widgets.py
 mode change 100644 => 100755 modules/plugin_dbui/cfgsvc.py

diff --git a/models/db_widgets.py b/models/db_widgets.py
old mode 100644
new mode 100755
index d2bdd48b..c29b2f8f
--- a/models/db_widgets.py
+++ b/models/db_widgets.py
@@ -37,16 +37,19 @@ dbui.configure_grids(db, plugins=['pGridRowEditor',
 #
 # Create composite fields for the publication form
 #
-fm = dbui.FieldModifier('publications')
-fm.configure_field('year', maxValue=datetime.now().year)
-
-fm.merge_fields('first_page', 
-                'last_page', 
-                extjs={'fieldLabel': T('Pages'), 'defaults': {'flex': 1}})
-
-fm.merge_fields('conference_start',
-                'conference_end',
-                extjs={'fieldLabel': T('Dates'), 'defaults': {'flex': 1}})
+fieldsModifier = dbui.FieldsModifier('publications')
+fieldsModifier.configure_field('year', 
+                               maxValue=datetime.now().year)
+
+fieldsModifier.merge_fields('first_page', 
+                            'last_page', 
+                            fieldLabel=T('Pages'), 
+                            defaults={'flex': 1})
+
+fieldsModifier.merge_fields('conference_start',
+                            'conference_end',
+                            fieldLabel=T('Dates'), 
+                            defaults={'flex': 1})
 
 #
 # Create fieldSet for the publication form
diff --git a/modules/plugin_dbui/cfgsvc.py b/modules/plugin_dbui/cfgsvc.py
old mode 100644
new mode 100755
index d0cfb5ae..d43727b5
--- a/modules/plugin_dbui/cfgsvc.py
+++ b/modules/plugin_dbui/cfgsvc.py
@@ -64,6 +64,8 @@ class CfgSvc(BaseSvc):
         See the documentation of the Ext.form.Compositefield class for details.
         
         """
+        
+        # handle composite field and fieldsets
         field_modifiers = self.environment['plugins'].dbui.field_modifiers
         if tablename in field_modifiers:
             field_modifier = field_modifiers[tablename]
@@ -74,6 +76,7 @@ class CfgSvc(BaseSvc):
             elif fieldname not in field_modifier.composite_fields.others:
                 li.append(self._get_form_field(tablename, fieldname))
  
+        # handle basic field
         else:
             li.append(self._get_form_field(tablename, fieldname))
 
diff --git a/modules/plugin_dbui/fieldsmodifier.py b/modules/plugin_dbui/fieldsmodifier.py
index fb9dadb3..1d397a0c 100755
--- a/modules/plugin_dbui/fieldsmodifier.py
+++ b/modules/plugin_dbui/fieldsmodifier.py
@@ -62,24 +62,19 @@ class FieldsModifier(Modifier):
         
         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.
                 
         """
-        extjs = {}
-        if 'extjs' in kwargs:
-            extjs.update(kwargs['extjs'])
-
 
+        # define the main field as the first field in the list
         main_field = fields[0]
         other_fields = fields[1:]
           
-        # NOTE
         # In order to simplify the processing keep a list of
-        # the main field, the first field appearing in the composite field,
-        # and a list of the other fields.
+        # the main field and a list of the other fields.
         self.data.composite_fields.main.append(main_field)
         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
-- 
GitLab