Skip to content
Snippets Groups Projects
Commit 47e1e442 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Review basesvc.py, extjs.py and fieldsmodifier.py documentations.

parent 469881eb
No related branches found
No related tags found
No related merge requests found
plugin_dbui.fieldsmodifier.FieldsModifier.append_plugins
========================================================
.. currentmodule:: plugin_dbui.fieldsmodifier
.. automethod:: FieldsModifier.append_plugins
\ No newline at end of file
plugin_dbui.fieldsmodifier.FieldsModifier.configure
===================================================
.. currentmodule:: plugin_dbui.fieldsmodifier
.. automethod:: FieldsModifier.configure
\ No newline at end of file
plugin_dbui.fieldsmodifier.FieldsModifier.configure_field
=========================================================
.. currentmodule:: plugin_dbui.fieldsmodifier
.. automethod:: FieldsModifier.configure_field
\ No newline at end of file
plugin_dbui.fieldsmodifier.FieldsModifier.merge_fields
======================================================
.. currentmodule:: plugin_dbui.fieldsmodifier
.. automethod:: FieldsModifier.merge_fields
\ No newline at end of file
...@@ -4,6 +4,7 @@ plugin_dbui.basesvc.BaseSvc ...@@ -4,6 +4,7 @@ plugin_dbui.basesvc.BaseSvc
.. currentmodule:: plugin_dbui.basesvc .. currentmodule:: plugin_dbui.basesvc
.. autoclass:: BaseSvc .. autoclass:: BaseSvc
:show-inheritance:
.. rubric:: Methods .. rubric:: Methods
......
plugin_dbui.extjs.Base
======================
.. currentmodule:: plugin_dbui.extjs
.. autoclass:: Base
:show-inheritance:
.. rubric:: Methods
.. autosummary::
:toctree: extjs/
~Base.append_items
~Base.append_plugins
plugin_dbui.fieldsmodifier.FieldsModifier
=========================================
.. currentmodule:: plugin_dbui.fieldsmodifier
.. autoclass:: FieldsModifier
:show-inheritance:
.. rubric:: Methods
.. autosummary::
:toctree: fieldsmodifier/
~FieldsModifier.append_plugins
~FieldsModifier.configure
~FieldsModifier.configure_field
~FieldsModifier.merge_fields
...@@ -15,28 +15,22 @@ class ExtJSException(BaseException): pass ...@@ -15,28 +15,22 @@ class ExtJSException(BaseException): pass
class Base(Storage): class Base(Storage):
"""Base class for Ext JS configurator. """Base class for Ext JS configurator.
The base class comes with two methods ``append_items``
and ``append_plugins``. They are required to append ``items``
and ``plugins``.
Note: Keyword Args:
A protection is set to avoid changing the ``xtype`` of the element. **kwargs: any Ext JS configuration parameter of the target class
Raises:
ExtJSException: when the keyword ``xtype`` is presented
in the keyword arguments.
Attributes:
xtype (str): the ``xtype`` of the target Ext JS widget.
""" """
xtype = None xtype = None
def __init__(self, **kwargs): def __init__(self, **kwargs):
"""
Keyword Args:
kwargs (dict):
any Ext JS configuration parameter of the target class
Raises:
ExtJSException:
when the keyword ``xtype`` is in the keyword arguments.
"""
if 'xtype' in kwargs: if 'xtype' in kwargs:
raise ExtJSException(MSG_XTYPE) raise ExtJSException(MSG_XTYPE)
...@@ -62,10 +56,24 @@ class Base(Storage): ...@@ -62,10 +56,24 @@ class Base(Storage):
def append_items(self, *args): def append_items(self, *args):
"""Append an widget configurations to the
internal items list.
Args:
*args: variable list of widget configuration.
"""
self._append('items', args) self._append('items', args)
def append_plugins(self, *args): def append_plugins(self, *args):
"""Append an plugin configurations to the
internal plugin list.
Args:
*args: variable list of plugin configuration.
"""
self._append('plugins', args) self._append('plugins', args)
......
...@@ -10,44 +10,35 @@ MODIFIER_FIELDS = 'modifier_fields' ...@@ -10,44 +10,35 @@ MODIFIER_FIELDS = 'modifier_fields'
class FieldsModifier(Modifier): class FieldsModifier(Modifier):
"""Modifier to customise the field widgets associated to a database table. """Customise the widgets associated to the fields of the database
table *tablename*.
Args:
tablename (str): name of the database table
Attributes: Attributes:
data.extjs_fields (dict): data (gluon.storage.Storage): storage containing the
data.composite_fields (gluon.storage.Storage): instructions to tune the field widgets. It has
two keys/attributes:
* extjs_fields (dict):
Ext JS configuration options for each field.
Keys are the database field names.
* composite_fields (gluon.storage.Storage):
describe the fields embedded in the :class:`.FieldContainer`.
It has two attributes:
* main (list): the first field of the container
* fields.others (list): the others field.
Fields are identified by their database field names
and should belong to the database table defined
in the constructor.
""" """
def __init__(self, tablename): def __init__(self, tablename):
"""Initialize the fields modifier associated to the database
table ``tablename``.
The data structure of the fields modifier can be access
outside the class::
p = PluginManager('dbui')
modifier = p.dbui['modifier_fields'][tablename]
or internally via the attribute ``data``.
The keys of the ``data`` structure are:
* ``extjs_fields`` (dict) Ext JS configuration options
for individual ``field``.
* ``composite_fields.main`` (list) the first field
of the ``FieldContainer``.
* ``composite_fields.others`` (list of list) the others field of
the ``FieldContainer``.
* There is one to one correspondence between the ``composite_fields.main``
and the ``composite_fields.others`` lists.
Args:
tablename (str): name of the database table
"""
Modifier.__init__(self, MODIFIER_FIELDS, tablename) Modifier.__init__(self, MODIFIER_FIELDS, tablename)
if 'extjs_fields' not in self.data: if 'extjs_fields' not in self.data:
...@@ -59,53 +50,74 @@ class FieldsModifier(Modifier): ...@@ -59,53 +50,74 @@ class FieldsModifier(Modifier):
def append_plugins(self, *plugins): def append_plugins(self, *plugins):
"""Overwrite the method of the base class since it make """Do nothing.
Supersede the method of the base class since it make
no sense for this modifier. no sense for this modifier.
Keyword Args:
*plugins: variable list of plugin names or configurations
""" """
def configure(self, **extjs): def configure(self, **extjs):
"""Overwrite the method of the base class since it make """Do nothing
Supersede the method of the base class since it make
no sense for this modifier. no sense for this modifier.
Keyword Args:
*extjs: any Ext JS configuration parameters.
""" """
def configure_field(self, field, **kwargs): def configure_field(self, field, **kwargs):
"""Update the configuration options of the Ext JS widget """Define the configuration options of the widget
associated to the ``field``. associated to the ``field``.
Existing value of the configuration options are replace by those Existing value of the configuration options are replace by those
defined by the keyword arguments. defined by the arguments.
Args: Args:
field (str): name of the database field. field (str): name of the database field.
It should belong to the database table defined It should belong to the database table defined
in the constructor. in the constructor.
Keyword Args:
**kwargs: any Ext JS configuration parameter of the widget class.
""" """
self.data.extjs_fields[field] = kwargs self.data.extjs_fields[field] = kwargs
def merge_fields(self, *fields, **kwargs): def merge_fields(self, *fields, **kwargs):
"""Merge fields in a ``FieldContainer``. """Merge *fields* in the container :class:`.FieldContainer`.
In form, the container is handled as a single widget
with a unique label. By default, it is the one of the first field
of the container. It can be supersede using the ``fieldLabel``
keyword argument.
The default configuration of the container is an horizontal layout:
The default configuration is with an horizontal layout with a unique .. code-block:: javascript
label defined by the keyword parameter ``fieldLabel``. More precisely,
the following Ext JS configuration parameters are set::
combineLabels = True, combineLabels = True,
defaults = {'flex': 1}, defaults = {'flex': 1},
layout = 'hbox' layout = 'hbox'
They can be super seed by the keyword arguments. It can be changed via the keyword arguments.
Args:
*fields: variable list of database field identified by their name.
They have to belong to the database table defined in the
constructor.
Note: Keyword Args:
* Each ``field`` is identified by its database field name. **kwargs: any configuration parameter of the
* ``field`` should belong to the database table defined in the constructor. ``Ext.form.FieldContainer``.
* The first ``field`` is the main field of the ``FieldContainer``.
* The keyword arguments contains the configuration options of
the ``Ext.form.FieldContainer`` widget.
""" """
# configuration of the FieldContainer # configuration of the FieldContainer
......
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