Skip to content
Snippets Groups Projects
Commit 99af6f10 authored by legac's avatar legac
Browse files

Add the possibility to defined array store in the model.

parent e6a2e930
No related branches found
No related tags found
No related merge requests found
...@@ -92,9 +92,7 @@ def dbui_conf(): ...@@ -92,9 +92,7 @@ def dbui_conf():
""" """
from gluon.contrib import simplejson as json from gluon.contrib import simplejson as json
dbui = local_import('plugin_dbui') dbui = local_import('plugin_dbui')
di = {} di = {}
dbui = local_import('plugin_dbui')
# build the dictionary required by Ext.direct # build the dictionary required by Ext.direct
# containing the definition of the remote procedure # containing the definition of the remote procedure
...@@ -111,8 +109,8 @@ def dbui_conf(): ...@@ -111,8 +109,8 @@ def dbui_conf():
di[action].append({'name': method, 'len': nargs}) di[action].append({'name': method, 'len': nargs})
# the stores configuration for each table # the stores configuration (static, for each table,...)
storeCfgs = {} storeCfgs = plugins.dbui.static_stores
for table in db: for table in db:
storeCfgs[table._tablename] = dbui.to_jsonstore(table) storeCfgs[table._tablename] = dbui.to_jsonstore(table)
......
...@@ -55,7 +55,9 @@ plugins = PluginManager('dbui', ...@@ -55,7 +55,9 @@ plugins = PluginManager('dbui',
modifier_forms={}, modifier_forms={},
modifier_grids={}, modifier_grids={},
modifier_stores={}, modifier_stores={},
modifier_viewports=Storage(extjs={})) modifier_viewports=Storage(extjs={}),
static_stores={})
# Start common services # Start common services
......
...@@ -3,6 +3,17 @@ ...@@ -3,6 +3,17 @@
""" """
# #
# Create a static store with the axes definition
#
dbui.AddStore('axes',
fields=['axis', 'granularity'],
data=[['projects', 'agency'],
['projects', 'project'],
['teams', 'domain'],
['teams', 'team'],
['time', 'year']],
xtype='arraystore')
#
# order store contents for technical tables # order store contents for technical tables
# #
storeModifier = dbui.StoreModifier('teams') storeModifier = dbui.StoreModifier('teams')
......
...@@ -42,7 +42,7 @@ from extjs import (CheckBox, ...@@ -42,7 +42,7 @@ from extjs import (CheckBox,
from fieldsmodifier import FieldsModifier from fieldsmodifier import FieldsModifier
from formmodifier import configure_forms, FormModifier from formmodifier import configure_forms, FormModifier
from gridmodifier import configure_grids, GridModifier from gridmodifier import configure_grids, GridModifier
from storemodifier import StoreModifier from storemodifier import AddStore, StoreModifier
from helper import (as_list, from helper import (as_list,
decode_field, decode_field,
encode_field, encode_field,
......
...@@ -2,13 +2,51 @@ ...@@ -2,13 +2,51 @@
""" """
from converter import STOREID
from gluon.storage import Storage from gluon.storage import Storage
from gluon.tools import PluginManager
from modifier import Modifier from modifier import Modifier
MODIFIER_STORES = 'modifier_stores' MODIFIER_STORES = 'modifier_stores'
class AddStore(object):
"""Helper tool to add the configuration of a store.
The configuration of all store are kept in a dedicated dictionary
which is given to the client via the action dbui_conf.
This tool is suited to defined static store (Ext.data.ArrayStore) used
for example in selectors. It should not be used to define store
associated to the database tables. The latter are configured using the
converter to_jsonstore.
However, this approach is generic and any store can be added to the
configuration dictionary.
"""
def __init__(self, name, **kwargs):
""" Create the configuration of a Store.
the ExtJS configuration parameters of the store are defined
by the keyword arguments kwargs.
For an Ext.data.ArrayStore the properties fields and data
have to be defined. For more details see the ExtJS documentation.
The key associated to this store in the configuration dictionary
is the storeId. It derived from the name in the
following way: nameStore.
"""
static_stores = PluginManager('dbui').dbui.static_stores
storeId = STOREID % name
kwargs['storeId'] = storeId
static_stores[storeId] = kwargs
class StoreModifier(Modifier): class StoreModifier(Modifier):
"""Helper tool to customize the store associated to a table. """Helper tool to customize the store associated to a table.
......
...@@ -4,6 +4,7 @@ HEAD ...@@ -4,6 +4,7 @@ HEAD
- New syntax for grid filter via the method GridModifier.append_filter. - New syntax for grid filter via the method GridModifier.append_filter.
- Improve the files organization defining the model. - Improve the files organization defining the model.
- Enable tab scrolling in viewport. - Enable tab scrolling in viewport.
- Add the possibility to define static store (Ext.data.ArrayStore) in the model.
0.4.8.2 (Jul 2012) 0.4.8.2 (Jul 2012)
- Consolidation version - Consolidation version
......
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