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

Backport the 0.5.x Spacer class.

parent 520d437d
No related branches found
No related tags found
No related merge requests found
......@@ -73,7 +73,7 @@ formModifier.merge_fields('conference_title',
'conference_town',
'id_countries',
'conference_speaker',
spacer=26*3,
dbui.Spacer(height=26*3),
title=T('Conference'),
flex=1)
......@@ -82,13 +82,13 @@ formModifier.merge_fields('authors_cppm',
'id_teams',
'id_projects',
'id_categories_aeres',
spacer= 26*5,
dbui.Spacer(height=26*5),
title='CPPM',
flex=1)
formModifier.merge_fields('report_numbers',
'id_reports',
spacer=220,
dbui.Spacer(height=220),
title=T('Report'),
flex=1)
......
......@@ -15,4 +15,5 @@ from helper import (get_js_files,
get_reference_paths,
get_script_path)
from mapper import map_default, map_tabpanel
from modifier import Spacer, Widget
from viewportmodifier import VIEWPORT_DP, ViewportModifier
\ No newline at end of file
......@@ -10,6 +10,7 @@ from basesvc import BaseSvc
from foreignfield import ForeignField
from helper import encode_field
from mapper import map_default
from modifier import Widget
from setfield import SetField
FIELD_IN_DBFIELD = "Field %s already in the dbFields list."
......@@ -64,6 +65,10 @@ class CfgSvc(BaseSvc):
See the documentation of the Ext.form.Compositefield class for details.
"""
# handle spacer and simple text widget
if isinstance(fieldname, Widget):
li.append(fieldname.extjs)
return
# handle composite field and fieldsets
field_modifiers = self.environment['plugins'].dbui.field_modifiers
......@@ -291,18 +296,9 @@ class CfgSvc(BaseSvc):
self._append_form_field(tablename, fieldname, cfg['items'])
if fieldname == 'id':
id_is_not_used = False
# protection when applying Ext JS configuration parameters
# NOTE: if the user submit a list of items they are append at the
# end of the current list.
# It is a way to add spacer and to fine tune the layout
extjs = dict(fieldset.extjs)
if 'items' in extjs:
cfg['items'].extend(extjs['items'])
del extjs['items']
# Apply the remaining Ext JS configuration options
cfg.update(extjs)
cfg.update(fieldset.extjs)
fielditems.append(cfg)
# append the field Id
......
......@@ -59,15 +59,6 @@ class FormModifier(Modifier):
extjs = {'defaults': {'anchor': '100%'}}
extjs.update(kwargs)
if 'spacer' in extjs:
di = {'xtype': 'spacer', 'height': extjs['spacer']}
if 'items' in extjs:
items.append(di)
else:
extjs['items'] = [di]
del extjs['spacer']
di = Storage(fields=fields, extjs= extjs)
self.data.field_sets.append(di)
......
......@@ -84,3 +84,20 @@ class Modifier(object):
"""
self.data.extjs.update(extjs)
class Widget(object):
"""Base class defining a the configuration of an ExtJS widget.
"""
def __init__(self, xtype, **kwargs):
self.extjs = dict(xtype=xtype, **kwargs)
class Spacer(Widget):
"""Define a spacer which can be add when combining fields in fieldset
or in field container.
"""
def __init__(self, **kwargs):
Widget.__init__(self, 'spacer', **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