diff --git a/static/plugin_dbui/src/appform.js b/static/plugin_dbui/src/appform.js index 9215665f95a23050add82e043ca46be92a9c2087..4a6c396f416da9707c774f883ae4c5c5a35388a3 100644 --- a/static/plugin_dbui/src/appform.js +++ b/static/plugin_dbui/src/appform.js @@ -21,8 +21,10 @@ App.form.FormPanel = Ext.extend(Ext.form.FormPanel, { /** * @cfg {Ext.data.Store} store the Ext.data.Store that the form should use. - * Mandatory configuration parameters. + * The store has to be defined since the actions rely on it. */ + store: null, + /** * Predefined configuration options */ @@ -76,17 +78,14 @@ App.form.FormPanel = Ext.extend(Ext.form.FormPanel, { this.addFieldToolTipsListeners(); // link the form to the data store - this.store = Ext.StoreMgr.lookup(this.store); + if (this.store) { + this.store = Ext.StoreMgr.lookup(this.store); + this.store.on('exception', this.onStoreException, this); + this.store.on('write', resetForm, this.getForm()); + } // set the default action: create this.setAction('create'); - - // Store events listeners - this.store.on('exception', this.onStoreException, this); - - // always reset the form after a write - // allow to enter data in a batch mode - this.store.on('write', resetForm, this.getForm()); }, /** @@ -118,7 +117,8 @@ App.form.FormPanel = Ext.extend(Ext.form.FormPanel, { /** * Handler to perform the current action on the store. * The current action is set by the setAction method. - * Should not be call directly, except for delete without confirmation. + * Should not be call directly, except for delete without confirmation. + * Raise an error if the store is not defined. */ doAction: function () { @@ -129,6 +129,10 @@ App.form.FormPanel = Ext.extend(Ext.form.FormPanel, { return; } + if (!this.store) { + throw new Error('the store is undefined !!!'); + } + switch (this.currentAction) { case 'create': @@ -227,12 +231,10 @@ App.form.FormPanel = Ext.extend(Ext.form.FormPanel, { this.currentAction = action; this.currentRecord = record; - this.hardReset(); - switch (action) { case 'create': - + this.hardReset(); this.buttonAction.setText(this.textCreate); break; @@ -243,6 +245,7 @@ App.form.FormPanel = Ext.extend(Ext.form.FormPanel, { case 'duplicate': this.buttonAction.setText(this.textDuplicate); + this.hardReset(); table = App.getTableName(this.store); tableId = App.encodeField(table, 'id'); delete record.data[tableId];