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

Modify the key for the store configuration (storeId).

New tool App.getStore to instanciate the any kind of store.
Remove the old tool App.getDirectStore.
parent 99af6f10
No related branches found
No related tags found
No related merge requests found
......@@ -112,7 +112,8 @@ def dbui_conf():
# the stores configuration (static, for each table,...)
storeCfgs = plugins.dbui.static_stores
for table in db:
storeCfgs[table._tablename] = dbui.to_jsonstore(table)
cfg = dbui.to_jsonstore(table)
storeCfgs[cfg['storeId']] = cfg
# the viewport configuration
viewportCfg = dbui.to_viewport()
......
......@@ -36,19 +36,20 @@ App.encodeField = function (table, field) {
};
/**
* Helper function returning the App.data.DirectStore identifies by its id.
* Helper function returning an App.data.Store identifies by its id.
* If the store does not exit it is created and register in the store manager.
*
* NOTE: The storeId is defined by the server for each widget.
* The syntax of the storeId is "tableStore".
* NOTE: The storeId is defined by the server.
* The syntax of the storeId is "nameStore".
* If the store does not exist, its configuration is extract from
* the application constant App.storeCfgs.Then it is created and registered.
* In the current frame work a unique store is associated to a database table.
* This property guaranty that widget share the same store.
*
* In the current frame work, this function allows to associated a unique store
* to a database table and that widget share the same store.
*
* @param {String} storeId
*/
App.getDirectStore = function (storeId) {
App.getStore = function (storeId) {
var cfg,
store,
......@@ -61,12 +62,39 @@ App.getDirectStore = function (storeId) {
}
if (!store && Ext.isString(storeId)) {
table = storeId.slice(0, storeId.search('Store'));
cfg = App.storeCfgs[table];
store = new App.data.DirectStore(cfg);
cfg = App.storeCfgs[storeId];
switch (cfg.xtype) {
case 'arraystore':
store = new Ext.data.ArrayStore(cfg);
break;
case 'directstore':
store = new Ext.data.DirectStore(cfg);
break;
case 'jsonstore':
store = new Ext.data.JsonStore(cfg);
break;
case 'store':
store = new Ext.data.Store(cfg);
break;
case 'xdirectstore':
store = new App.data.DirectStore(cfg);
break;
case 'xmlstore':
store = new Ext.data.XmlStore(cfg);
break;
default:
throw new Error('Fail to instanciate the object: "' + cfg.xtype + '"');
break;
}
}
return store;
};
......
......@@ -32,7 +32,7 @@ App.form.ComboBox = Ext.extend(Ext.form.ComboBox, {
}
// link the combobox to the data store
this.store = App.getDirectStore(this.store);
this.store = App.getStore(this.store);
// construct the underlying class. DON'T MOVE
App.form.ComboBox.superclass.initComponent.call(this);
......
......@@ -77,7 +77,7 @@ App.form.FormPanel = Ext.extend(Ext.form.FormPanel, {
this.buttonReset.on('click', resetForm, this.getForm());
// link the form to the data store
this.store = App.getDirectStore(this.store);
this.store = App.getStore(this.store);
this.store.on('exception', this.onStoreException, this);
this.store.on('write', resetForm, this.getForm());
......
......@@ -44,7 +44,7 @@ App.grid.Grid = Ext.extend(Ext.grid.GridPanel, {
initComponent: function () {
// link the grid to the data store
this.store = App.getDirectStore(this.store);
this.store = App.getStore(this.store);
// empty toolBar requires by the plugins
this.bbar = new Ext.Toolbar();
......
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