diff --git a/controllers/plugin_dbui.py b/controllers/plugin_dbui.py index 9b0b7f97c42611723597f8c91e3b68e403a8f597..e6f8281db867476d6efccbc321276eacce8120ed 100644 --- a/controllers/plugin_dbui.py +++ b/controllers/plugin_dbui.py @@ -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() diff --git a/static/plugin_dbui/src/appbase.js b/static/plugin_dbui/src/appbase.js index a9a9dedb466c1e1fbcef744e8f9b646bce9a7b26..441137b5cb6bdf43a723bedf0904891c18f80742 100644 --- a/static/plugin_dbui/src/appbase.js +++ b/static/plugin_dbui/src/appbase.js @@ -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; }; diff --git a/static/plugin_dbui/src/appcombobox.js b/static/plugin_dbui/src/appcombobox.js index 86cd26f677c41245fcb36cfabdf591adae7928ed..f5fb3bd188b3c74ee6133db1e2646b8473db50c8 100644 --- a/static/plugin_dbui/src/appcombobox.js +++ b/static/plugin_dbui/src/appcombobox.js @@ -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); diff --git a/static/plugin_dbui/src/appform.js b/static/plugin_dbui/src/appform.js index 2c75439c6623b265863b509f88c24c76a304008a..b34dd6247a7027b94ec164af2508048a07208906 100644 --- a/static/plugin_dbui/src/appform.js +++ b/static/plugin_dbui/src/appform.js @@ -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()); diff --git a/static/plugin_dbui/src/appgrid.js b/static/plugin_dbui/src/appgrid.js index e1885fac15be4bfd78d0a4aec03d6971e05943d8..4d1ac9b33008f05a2a6f50c5b2151e383d85bd67 100644 --- a/static/plugin_dbui/src/appgrid.js +++ b/static/plugin_dbui/src/appgrid.js @@ -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();