From 2eb062c7d59e513c9f214b62dc13c024fade66a8 Mon Sep 17 00:00:00 2001 From: Renaud Le Gac <renaud.legac@free.fr> Date: Thu, 13 Jan 2011 22:23:30 +0000 Subject: [PATCH] Modification to be compliant with JSlint (the good parts) --- static/plugin_dbui/lib/appbase.js | 6 +- static/plugin_dbui/lib/appcombobox.js | 30 +++--- static/plugin_dbui/lib/appform.js | 21 ++-- static/plugin_dbui/lib/appform2.js | 65 ++++++------ static/plugin_dbui/lib/appgrid.js | 49 +++++---- static/plugin_dbui/lib/appgridfilter.js | 70 ++++++++----- static/plugin_dbui/lib/appgridmathjax.js | 14 +-- static/plugin_dbui/lib/appgridpaging.js | 33 ++++--- static/plugin_dbui/lib/appgridroweditor.js | 99 ++++++++++--------- .../lib/appgridroweditorcontextmenu.js | 14 +-- .../lib/appgridroweditortoolbar.js | 12 ++- static/plugin_dbui/lib/appjsonstore.js | 64 ++++++------ static/plugin_dbui/lib/appmgr.js | 42 ++++---- static/plugin_dbui/lib/apppanelmathjax.js | 10 +- static/plugin_dbui/lib/appsetbox.js | 18 ++-- static/plugin_dbui/lib/appviewportcfg.js | 30 +++--- .../plugin_dbui/lib/appviewportintreebase.js | 70 ++++++------- .../plugin_dbui/lib/appviewportintreeform.js | 25 ++--- .../plugin_dbui/lib/appviewportintreegrid.js | 41 ++++---- 19 files changed, 388 insertions(+), 325 deletions(-) diff --git a/static/plugin_dbui/lib/appbase.js b/static/plugin_dbui/lib/appbase.js index 10f0c0f2..67a2c932 100644 --- a/static/plugin_dbui/lib/appbase.js +++ b/static/plugin_dbui/lib/appbase.js @@ -43,11 +43,11 @@ App.dburl = '/' + App.name + '/plugin_dbui/database'; App.cfgSvcMethods = { "url": '/' + App.name + '/plugin_dbui/configuration', - "type":"remoting", + "type": "remoting", "actions": { "cfgSvc": [{'name': 'getFormModel', 'len': 1}, {'name': 'getGridModel', 'len': 1}, - {'name': 'getTables', 'len': 0}] + {'name': 'getTables', 'len': 0}] } }; @@ -55,7 +55,7 @@ App.cfgSvcMethods = { * Helper function to load the MathJax librairy * @param {Object} callback */ -App.loadMathJax = function(callback, scope){ +App.loadMathJax = function (callback, scope) { var path = '/' + App.name + '/static/plugin_mathjax/MathJax.js'; Ext.Loader.load([path], callback, scope); }; diff --git a/static/plugin_dbui/lib/appcombobox.js b/static/plugin_dbui/lib/appcombobox.js index 1303815d..699de074 100644 --- a/static/plugin_dbui/lib/appcombobox.js +++ b/static/plugin_dbui/lib/appcombobox.js @@ -3,9 +3,9 @@ * Design to work with the class DbSvc on the server side. * * MANDATORY PROPERTIES: - * - model model to configure the object provide by the server - * - displayField field of the table shown in the combobox - * - valueField field of the table return by the combobox + * - model model to configure the object provide by the server + * - displayField field of the table shown in the combobox + * - valueField field of the table return by the combobox * * All configuration properties of Ext.form.ComboBox are understood. * @@ -21,11 +21,11 @@ App.form.ComboBox = Ext.extend(Ext.form.ComboBox, { /** * @cfg {Object} model Object to configure the widget. * It is provided by the server and contains the following keys: - * { store: { - * table: 'x', - * dbFields: [(table1, field1), (table1, field2)], - * fields: [field1, field2], - * debug: false} + * { store: { + * table: 'x', + * dbFields: [(table1, field1), (table1, field2)], + * fields: [field1, field2], + * debug: false} * } */ model: null, @@ -34,7 +34,7 @@ App.form.ComboBox = Ext.extend(Ext.form.ComboBox, { * Predefined setting * */ - mode:'remote', + mode: 'remote', editable: false, selectOnFocus: true, triggerAction: 'all', @@ -43,11 +43,11 @@ App.form.ComboBox = Ext.extend(Ext.form.ComboBox, { /** * private method require by the ExtJs component model */ - initComponent: function(){ + initComponent: function () { // defined the empty text from the field label - if(this.fieldLabel && !this.emptyText){ - this.emptyText = "Select a "+this.fieldLabel+" ..."; + if (this.fieldLabel && !this.emptyText) { + this.emptyText = "Select a " + this.fieldLabel + " ..."; } // setup the store if not defined by the user @@ -60,7 +60,7 @@ App.form.ComboBox = Ext.extend(Ext.form.ComboBox, { model: this.model.store, debug: App.debug, sortInfo: {field: this.displayField}, - autoLoad: true, + autoLoad: true }); } @@ -69,10 +69,10 @@ App.form.ComboBox = Ext.extend(Ext.form.ComboBox, { // This few lines are required to set a value // when the combobox is not yet expend - this.store.on('load', function(){ + this.store.on('load', function () { this.setValue(this.getValue()); }, this); - }, + } }); Ext.reg('xcombobox', App.form.ComboBox); diff --git a/static/plugin_dbui/lib/appform.js b/static/plugin_dbui/lib/appform.js index 62fc166a..a06538d6 100644 --- a/static/plugin_dbui/lib/appform.js +++ b/static/plugin_dbui/lib/appform.js @@ -29,7 +29,7 @@ App.form.FormPanel = Ext.extend(Ext.form.FormPanel, { bodyStyle: 'padding:5px 5px 0', buttons: [{ text: 'Clear', - ref: '../buttonClear', + ref: '../buttonClear' }, { text: 'Create', ref: '../buttonCreate' @@ -49,22 +49,23 @@ App.form.FormPanel = Ext.extend(Ext.form.FormPanel, { /** * private method require by the ExtJs component model */ - initComponent: function(){ + initComponent: function () { // construct the underlying class. DON'T MOVE App.form.FormPanel.superclass.initComponent.call(this); // reset the form - this.buttonClear.on('click', function(){this.reset();}, this.getForm()); + this.buttonClear.on('click', function () {this.reset(); }, this.getForm()); }, /** * Helper function to enable/disable all fields of the form * @param {Object} bool */ - setFieldsDisable: function(bool){ - var form = this.getForm(); - for (var i = 0; i < form.items.length; i++) { + setFieldsDisable: function (bool) { + var form, i; + form = this.getForm(); + for (i = 0; i < form.items.length; i += 1) { form.items.itemAt(i).setDisabled(bool); } }, @@ -72,7 +73,7 @@ App.form.FormPanel = Ext.extend(Ext.form.FormPanel, { /** * Show the delete button and hide the others */ - showButtonDelete: function(){ + showButtonDelete: function () { this.buttonDelete.show(); this.buttonCreate.hide(); this.buttonUpdate.hide(); @@ -81,7 +82,7 @@ App.form.FormPanel = Ext.extend(Ext.form.FormPanel, { /** * Show the Create button and hide the others */ - showButtonCreate: function(){ + showButtonCreate: function () { this.buttonDelete.hide(); this.buttonCreate.show(); this.buttonUpdate.hide(); @@ -90,11 +91,11 @@ App.form.FormPanel = Ext.extend(Ext.form.FormPanel, { /** * Show the Update button and hide the others */ - showButtonUpdate: function(){ + showButtonUpdate: function () { this.buttonDelete.hide(); this.buttonCreate.hide(); this.buttonUpdate.show(); - }, + } }); Ext.reg('xform', App.form.FormPanel); diff --git a/static/plugin_dbui/lib/appform2.js b/static/plugin_dbui/lib/appform2.js index 8e13d360..2b8af001 100644 --- a/static/plugin_dbui/lib/appform2.js +++ b/static/plugin_dbui/lib/appform2.js @@ -3,8 +3,8 @@ * Design to work with the class HttpDb on the server side. * * MANDATORY PROPERTIES: - * - url the url of the server - * - table the name of the database table + * - url the url of the server + * - table the name of the database table * * All configuration properties of Ext.form.FormPanel are understood. * @@ -21,17 +21,32 @@ Ext.namespace('App.form'); +/** + * Helper function to render the tooltip associate to a field + * @param {Object} c + */ +App.form.setToolTip = function (c) { + Ext.ToolTip({ + target: c.getEl(), + title: c.fieldLabel, + anchor: 'left', + trackMouse: false, + html: Ext.util.Format.htmlEncode(c.tipText) + }); +}; + + App.form.EntryFormPanel = Ext.extend(App.form.FormPanel, { /** * @cfg {Object} model Object to configure the widget * for a table of the database. It is provided by the server * and contains the following keys: - * { - * item: [...], - * table: 'x', - * title: 'y', - * xtype: 'xentry' + * + * item: [...], + * table: 'x', + * title: 'y', + * xtype: 'xentry' * } */ model: null, @@ -39,10 +54,12 @@ App.form.EntryFormPanel = Ext.extend(App.form.FormPanel, { /** * private method require by the ExtJs component model */ - initComponent: function(){ + initComponent: function () { - if (!this.model){ - throw new Error("the property model is missing !!!") + var fields, field, i; + + if (!this.model) { + throw new Error("the property model is missing !!!"); } // define the item and the url @@ -55,19 +72,11 @@ App.form.EntryFormPanel = Ext.extend(App.form.FormPanel, { // Add handler to display tool tip for each field // Require the configuration parameter tipText. - var fields = this.findByType('field'); - for (var i = 0; i < fields.length; i++){ - var field = fields[i]; - if (field.tipText){ - field.on('render', function(c){ - new Ext.ToolTip({ - target: c.getEl(), - title: c.fieldLabel, - anchor: 'left', - trackMouse: false, - html: Ext.util.Format.htmlEncode(c.tipText), - }); - }); + fields = this.findByType('field'); + for (i = 0; i < fields.length; i += 1){ + field = fields[i]; + if (field.tipText) { + field.on('render', App.form.setToolTip); } } }, @@ -75,7 +84,7 @@ App.form.EntryFormPanel = Ext.extend(App.form.FormPanel, { /** * Private handler to submit values in the database */ - onSubmit: function(){ + onSubmit: function () { this.getForm().submit({ clientValidation: true, @@ -88,15 +97,15 @@ App.form.EntryFormPanel = Ext.extend(App.form.FormPanel, { }, reset: true, waitMsg: 'Saving Record...', - failure: function(form, action){ + failure: function (form, action) { if (action.response) { - if (action.response.status != 200) { + if (action.response.status !== 200) { Ext.MessageBox.alert('Error', action.response.responseText); } } - }, + } }); - }, + } }); Ext.reg('xentry', App.form.EntryFormPanel); diff --git a/static/plugin_dbui/lib/appgrid.js b/static/plugin_dbui/lib/appgrid.js index b647c1b1..335fe124 100644 --- a/static/plugin_dbui/lib/appgrid.js +++ b/static/plugin_dbui/lib/appgrid.js @@ -18,13 +18,13 @@ App.grid.Grid = Ext.extend(Ext.grid.GridPanel, { * @cfg {Object} model Object to configure the widget * for a table of the database. It is provided by the server * and contains the following keys: - * { - * colModel: [...], - * formModel: [...], - * store: {}, - * table: 'x', - * title: 'y', - * xtype: 'xgrid' + * + * colModel: [...], + * formModel: [...], + * store: {}, + * table: 'x', + * title: 'y', + * xtype: 'xgrid' * } */ model: null, @@ -46,10 +46,10 @@ App.grid.Grid = Ext.extend(Ext.grid.GridPanel, { /** * private method requests by the component model of Extjs */ - initComponent: function(){ + initComponent: function () { - if (!this.model){ - throw new Error("the property model is missing !!!") + if (!this.model) { + throw new Error("the property model is missing !!!"); } // grid title @@ -88,14 +88,16 @@ App.grid.Grid = Ext.extend(Ext.grid.GridPanel, { * * @param {Object} grid */ - onBeforeRender: function(grid){ + onBeforeRender: function (grid) { + + var i, isPagingPlugin; // is the paging plugin ? - var isPagingPlugin = false; - if( 'plugins' in grid){ - for (var i = 0; i < grid.plugins.length; i++){ - if( 'ptype' in grid.plugins[i]){ - if( grid.plugins[i].ptype == 'pGridPaging'){ + isPagingPlugin = false; + if ('plugins' in grid) { + for (i = 0; i < grid.plugins.length; i += 1) { + if ('ptype' in grid.plugins[i]) { + if (grid.plugins[i].ptype === 'pGridPaging') { isPagingPlugin = true; break; } @@ -108,17 +110,12 @@ App.grid.Grid = Ext.extend(Ext.grid.GridPanel, { // number of records. It is why we only ask the first one. // When the store will be loaded, the paging plugin will tune // the number of rows per page and will reload the store accordingly. - if( isPagingPlugin) - grid.store.load({ - params: { - start: 0, - limit: 1 - } - }); - - else + if (isPagingPlugin) { + grid.store.load({params: {start: 0, limit: 1}}); + } + else { grid.store.load(); - + } return true; } }); diff --git a/static/plugin_dbui/lib/appgridfilter.js b/static/plugin_dbui/lib/appgridfilter.js index 59f84a02..608e557f 100644 --- a/static/plugin_dbui/lib/appgridfilter.js +++ b/static/plugin_dbui/lib/appgridfilter.js @@ -48,24 +48,28 @@ App.grid.GridFilter = Ext.extend(Ext.form.FieldSet, { /** * private method requests by the component model of Ext JS */ - initComponent: function(){ + initComponent: function () { + var field, fields, i; + // initialize the underlying class. App.grid.GridFilter.superclass.initComponent.call(this); // associate handlers to fields - var fields = this.findByType('field'); - for (var i = 0; i < fields.length; i++){ + fields = this.findByType('field'); + for (i = 0; i < fields.length; i += 1) { field = fields[i]; // catch a change of value for combobox - if (field.xtype == 'xcombobox') + if (field.xtype === 'xcombobox') { field.on('select', this.onChange, this); + } // catch the key pressed enter for other fields // wait that user finish to type to run the handler - else + else { field.on('keyup', this.onChange, this, {buffer: 500}); + } } }, @@ -73,17 +77,20 @@ App.grid.GridFilter = Ext.extend(Ext.form.FieldSet, { * Bind the grid filter to the grid * @param {Ext.grid.GridPanel} grid */ - bind: function(grid){ + bind: function (grid) { + var baseParams, i; + this.store = grid.getStore(); // paging toolbar ? - if(grid.pagingInitialized) + if (grid.pagingInitialized) { this.pagingToolbar = grid.getBottomToolbar(); - + } + // initial filter conditions - var baseParams = this.store.baseParams; - for( var i = 0; i < baseParams.where.length; i++){ + baseParams = this.store.baseParams; + for (i = 0; i < baseParams.where.length; i += 1) { this.initialFilterConditions.push(baseParams.where[i]); } @@ -92,20 +99,22 @@ App.grid.GridFilter = Ext.extend(Ext.form.FieldSet, { /** * Handler to catch a change in field value */ - onChange: function(field){ + onChange: function (field) { this.setupCondition(field); }, /** * Handler to reset the filter */ - onReset: function(){ + onReset: function () { + + var fields, i; // reset the field value - var fields = this.findByType('field'); - for (var i = 0; i < fields.length; i++) { + fields = this.findByType('field'); + for (i = 0; i < fields.length; i += 1) { fields[i].reset(); - }; + } // reset filter conditions this.filterConditions = {}; @@ -119,25 +128,30 @@ App.grid.GridFilter = Ext.extend(Ext.form.FieldSet, { * Setup condition * @param {Ext.form.Field} */ - setupCondition: function(field){ + setupCondition: function (field) { + var conditions = [], i, k, value, where; + // get the field value and update the condition dictionary - var value = field.getValue(); - var where = field.name + " " + field.filterOperator + " '" + value + "'"; + value = field.getValue(); + where = field.name + " " + field.filterOperator + " '" + value + "'"; - if( value == '') + if (value === '') { delete this.filterConditions[field.name]; - else + } + else { this.filterConditions[field.name] = where; + } // build the complete where clause - var conditions = []; - for( var i = 0; i < this.initialFilterConditions.length; i++){ + for (i = 0; i < this.initialFilterConditions.length; i += 1){ conditions.push(this.initialFilterConditions[i]); } for( k in this.filterConditions){ - conditions.push(this.filterConditions[k]); + if (this.filterConditions.hasOwnProperty(k)) { + conditions.push(this.filterConditions[k]); + } } // push new condition in the where clause of the store @@ -151,12 +165,14 @@ App.grid.GridFilter = Ext.extend(Ext.form.FieldSet, { * private * Helper function to load the store applying filter conditions */ - updateStore: function(){ + updateStore: function () { - if (this.pagingToolbar) + if (this.pagingToolbar) { this.pagingToolbar.doRefresh(); - else - this.store.load(); + } + else { + this.store.load(); + } } }); diff --git a/static/plugin_dbui/lib/appgridmathjax.js b/static/plugin_dbui/lib/appgridmathjax.js index 9b9065f1..ae957724 100644 --- a/static/plugin_dbui/lib/appgridmathjax.js +++ b/static/plugin_dbui/lib/appgridmathjax.js @@ -10,15 +10,15 @@ Ext.namespace('App.grid'); App.grid.MathJax = Ext.extend(Object, { - - init: function(grid){ - grid.getView().on('refresh', function(){ - MathJax.Hub.PreProcess(); - MathJax.Hub.Process(); - }) + init: function (grid) { + + grid.getView().on('refresh', function () { + MathJax.Hub.PreProcess(); + MathJax.Hub.Process(); + }); - }, + } }); Ext.preg('pGridMathJax', App.grid.MathJax); \ No newline at end of file diff --git a/static/plugin_dbui/lib/appgridpaging.js b/static/plugin_dbui/lib/appgridpaging.js index 0cd6091f..1891ec9c 100644 --- a/static/plugin_dbui/lib/appgridpaging.js +++ b/static/plugin_dbui/lib/appgridpaging.js @@ -17,30 +17,32 @@ App.grid.Paging = Ext.extend(Object, { /** * Plugin intialisation */ - init: function(grid){ + init: function (grid) { + var bbar; + grid.pagingInitialized = false; // associate the bbar to the grid store - var bbar = grid.getBottomToolbar(); + bbar = grid.getBottomToolbar(); bbar.bindStore(grid.store); // add the slider and the export button bbar.add('-', 'Rows per page', { - xtype: 'slider', + xtype: 'slider', plugins: new Ext.slider.Tip(), listeners: {changecomplete: this.onChangePageSize, scope: bbar}, minValue: 1, - width: 100, + width: 100 }, '->', { - xtype: 'button', + xtype: 'button', text: 'Export to CSV', - listeners: {click: this.onExport}, + listeners: {click: this.onExport} } ); @@ -57,7 +59,7 @@ App.grid.Paging = Ext.extend(Object, { /** * Handler to change the number of rows per page */ - onChangePageSize: function(slider, newValue, thumb){ + onChangePageSize: function (slider, newValue, thumb) { var bbar = this; bbar.pageSize = newValue; bbar.moveFirst(); @@ -66,37 +68,38 @@ App.grid.Paging = Ext.extend(Object, { /** * Handler to export the grid content as a CSV file */ - onExport: function(button ,event){ + onExport: function (button, event) { Ext.Msg.alert('Warning', 'Functionality not yet implemented'); }, /** * Handler to tune the number of rows per page and the number of page */ - onStoreLoad: function(store, records, options){ + onStoreLoad: function (store, records, options) { - var grid = this; - if(grid.pagingInitialized) + var bbar, grid = this, nRows = 10, slider; + + if (grid.pagingInitialized) { return; + } grid.pagingInitialized = true; - var bbar = grid.getBottomToolbar(); - var slider = bbar.findByType('slider')[0]; + bbar = grid.getBottomToolbar(); + slider = bbar.findByType('slider')[0]; // NOTE: the number of row which visible in the browser // can be obtained having a look to the DOM tree finding // CSS component name x-grid3-cell-inner. Then by comparing // the innerHeight of the browser window and the height of the // cell we can compute the number of rows ? For later !! - var nRows = 10 slider.maxValue = store.totalLength; slider.setValue(nRows); bbar.pageSize = nRows; bbar.moveFirst(); - }, + } }); diff --git a/static/plugin_dbui/lib/appgridroweditor.js b/static/plugin_dbui/lib/appgridroweditor.js index 3f0827a0..7415268d 100644 --- a/static/plugin_dbui/lib/appgridroweditor.js +++ b/static/plugin_dbui/lib/appgridroweditor.js @@ -47,7 +47,7 @@ App.grid.RowEditor = Ext.extend(Ext.Window, { /** * private method request by the EXtJs component model */ - initComponent: function(){ + initComponent: function () { // create the FormPanel embedded in the window this.items = [this.formModel]; @@ -60,8 +60,10 @@ App.grid.RowEditor = Ext.extend(Ext.Window, { * * @param {Object} grid GridPanel the grid instantiating the plugin */ - init: function(grid){ + init: function (grid) { + var cbrec, combo, combos, i, item, values; + this.grid = grid; this.formPanel = this.items.first(); @@ -70,7 +72,7 @@ App.grid.RowEditor = Ext.extend(Ext.Window, { // The user can only select one row of the grid this.grid.selModel = new Ext.grid.RowSelectionModel({ - singleSelect: true, + singleSelect: true }); // Switch off the autoSave mode of the store @@ -85,18 +87,20 @@ App.grid.RowEditor = Ext.extend(Ext.Window, { // HACK: In version 3.2.1 the data in the record are lost somewhere // As a consequence, the values appearing in the grid after an // update are empty. This fix correct this issue. - this.grid.store.on("update", function(store, rec, op){ - if(op == Ext.data.Record.COMMIT && Ext.version >= '3.2.1'){ - - var values = this.formPanel.getForm().getValues(); - for(item in values){ - rec.data[item] = values[item]; + this.grid.store.on("update", function (store, rec, op) { + if (op === Ext.data.Record.COMMIT && Ext.version >= '3.2.1') { + + values = this.formPanel.getForm().getValues(); + for (item in values) { + if (values.hasOwnProperty(item)) { + rec.data[item] = values[item]; + } } - var combos = this.findByType('xcombobox'); - for (var i = 0; i < combos.length; i++){ - var combo = combos[i]; - var cbrec = combo.findRecord(combo.valueField, combo.getValue()); + combos = this.findByType('xcombobox'); + for (i = 0; i < combos.length; i += 1) { + combo = combos[i]; + cbrec = combo.findRecord(combo.valueField, combo.getValue()); rec.data[combo.displayField] = cbrec.get(combo.displayField); } @@ -108,25 +112,27 @@ App.grid.RowEditor = Ext.extend(Ext.Window, { * Private function to add a row in the grid using form values * The scope of this function is the App.grid.RowEditor */ - addRowFromForm: function(){ + addRowFromForm: function () { + var i, rec, record; + // Returns true if client-side validation on the form is successful. - if(! this.formPanel.getForm().isValid()){ + if (!this.formPanel.getForm().isValid()) { Ext.Msg.alert('Error', 'Few fields in the form are not valid !'); return; } // generate a fresh new record // update its with values found in the form - var record = new this.grid.store.recordType(); + record = new this.grid.store.recordType(); this.updateRecord(record); // insert the new record below the selected one // if no record is selected insert at the beginning of the store // the later append when the user click the button in the tool bar - var rec = this.grid.getSelectionModel().getSelected(); - var i = this.grid.store.indexOf(rec); - this.grid.store.insert(i+1, record); + rec = this.grid.getSelectionModel().getSelected(); + i = this.grid.store.indexOf(rec); + this.grid.store.insert(i + 1, record); // save the change in the database this.grid.store.save(); @@ -136,16 +142,18 @@ App.grid.RowEditor = Ext.extend(Ext.Window, { * Private method to update an existing row using form values * The scope of this function is the App.grid.RowEditor */ - editRowFromForm: function(){ + editRowFromForm: function () { + + var record; // Returns true if client-side validation on the form is successful. - if(! this.formPanel.getForm().isValid()){ + if (!this.formPanel.getForm().isValid()) { Ext.Msg.alert('Error', 'Few fields in the form are not valid !'); return; } // update the selected record with modified values - var record = this.getSelected(); + record = this.getSelected(); this.updateRecord(record); // save the change in the database @@ -161,7 +169,7 @@ App.grid.RowEditor = Ext.extend(Ext.Window, { * @param {Object} batch * @param {Object} data */ - endEdit: function(store, batch, data){ + endEdit: function (store, batch, data) { // clear the form panel this.formPanel.getForm().reset(); @@ -177,7 +185,7 @@ App.grid.RowEditor = Ext.extend(Ext.Window, { * In absence of selected row a warning message is shown * and the function return false. */ - getSelected: function(){ + getSelected: function () { var rec = this.grid.getSelectionModel().getSelected(); @@ -195,7 +203,7 @@ App.grid.RowEditor = Ext.extend(Ext.Window, { * It has to be the equal to the plugin object. * */ - onAddRow: function(){ + onAddRow: function () { this.setTitle("Create a new record..."); this.show(); @@ -210,10 +218,10 @@ App.grid.RowEditor = Ext.extend(Ext.Window, { * It has to be the equal to the plugin object. * */ - onDeleteRow: function(){ + onDeleteRow: function () { var record = this.getSelected(); - if (! record) {return} + if (!record) {return; } this.grid.store.remove(record); this.grid.store.save(); @@ -225,10 +233,10 @@ App.grid.RowEditor = Ext.extend(Ext.Window, { * It has to be the equal to the plugin object. * */ - onDuplicateRow: function(){ + onDuplicateRow: function () { var record = this.getSelected(); - if (! record) {return} + if (!record) {return; } this.setTitle("Duplicate the record..."); this.show(); @@ -244,10 +252,10 @@ App.grid.RowEditor = Ext.extend(Ext.Window, { * It has to be the equal to the plugin object. * */ - onEditRow: function(){ + onEditRow: function () { var record = this.getSelected(); - if (! record) {return} + if (!record) {return; } this.setTitle("Update the record..."); this.show(); @@ -266,10 +274,10 @@ App.grid.RowEditor = Ext.extend(Ext.Window, { * Interactions with the database are switch off. * */ - onViewRow: function(){ + onViewRow: function () { var record = this.getSelected(); - if (! record) {return} + if (!record) {return; } this.setTitle("View the record..."); this.show(); @@ -279,8 +287,7 @@ App.grid.RowEditor = Ext.extend(Ext.Window, { this.formPanel.buttonClear.hide(); this.formPanel.buttonCreate.hide(); - - this.on("hide", function(){ + this.on("hide", function () { this.formPanel.buttonClear.show(); this.formPanel.buttonCreate.show(); }, this); @@ -291,22 +298,26 @@ App.grid.RowEditor = Ext.extend(Ext.Window, { * Private function to update the selected record with the value of the form * @param {Object} record */ - updateRecord: function(record){ - + updateRecord: function (record) { + + var combo, combos, i, item, rec, values; + // Recuperate all values from the form - var values = this.formPanel.getForm().getValues(); - for(item in values){ - record.set(item, values[item]); + values = this.formPanel.getForm().getValues(); + for (item in values) { + if (values.hasOwnProperty(item)) { + record.set(item, values[item]); + } } // For foreign key, the record display in the grid contains the // valueField as well as the displayField. // Previous action update the vlueField but note the display field. // the next line append the displayField - var combos = this.findByType('xcombobox'); - for (var i = 0; i < combos.length; i++){ - var combo = combos[i]; - var rec = combo.findRecord(combo.valueField, combo.getValue()); + combos = this.findByType('xcombobox'); + for (i = 0; i < combos.length; i += 1) { + combo = combos[i]; + rec = combo.findRecord(combo.valueField, combo.getValue()); record.set(combo.displayField, rec.get(combo.displayField)); } diff --git a/static/plugin_dbui/lib/appgridroweditorcontextmenu.js b/static/plugin_dbui/lib/appgridroweditorcontextmenu.js index 7a07ffb9..b81904e9 100644 --- a/static/plugin_dbui/lib/appgridroweditorcontextmenu.js +++ b/static/plugin_dbui/lib/appgridroweditorcontextmenu.js @@ -24,15 +24,15 @@ App.grid.RowEditorContextMenu = Ext.extend(Object, { * Plugin intialisation * @param {Object} grid */ - init: function(grid){ + init: function (grid) { var menu = new Ext.menu.Menu(); // create and initialize the underlying RowEditor - if (!grid.editor){ + if (!grid.editor) { grid.editor = new App.grid.RowEditor({ formModel: grid.model.formModel, - table: grid.model.table, + table: grid.model.table }); grid.editor.init(grid); @@ -73,7 +73,7 @@ App.grid.RowEditorContextMenu = Ext.extend(Object, { /** * Handler displaying the row context menu in an empty grid */ - onContainerContextMenu: function(grid, event){ + onContainerContextMenu: function (grid, event) { var menu = this; event.stopEvent(); @@ -84,7 +84,7 @@ App.grid.RowEditorContextMenu = Ext.extend(Object, { * Handler displaying the context menu in the header * Nothing is display in that case. */ - onHeaderContextMenu: function(grid, columIndex, event){ + onHeaderContextMenu: function (grid, columIndex, event) { event.stopEvent(); }, /** @@ -92,7 +92,7 @@ App.grid.RowEditorContextMenu = Ext.extend(Object, { * The scope use by the handler is defined by the caller. * It has to be the equal to the menu object. */ - onRowContextMenu: function(grid, rowIndex, event){ + onRowContextMenu: function (grid, rowIndex, event) { var menu = this; @@ -100,7 +100,7 @@ App.grid.RowEditorContextMenu = Ext.extend(Object, { grid.selModel.selectRow(rowIndex); menu.showAt(event.getXY()); - }, + } }); diff --git a/static/plugin_dbui/lib/appgridroweditortoolbar.js b/static/plugin_dbui/lib/appgridroweditortoolbar.js index 5d964ebe..74ce2b67 100644 --- a/static/plugin_dbui/lib/appgridroweditortoolbar.js +++ b/static/plugin_dbui/lib/appgridroweditortoolbar.js @@ -22,19 +22,21 @@ App.grid.RowEditorToolbar = Ext.extend(Object, { * Plugin intiaisation * @param {Object} grid */ - init: function(grid){ + init: function (grid) { + var toolbar; + // create and initialize the underlying RowEditor - if (!grid.editor){ + if (!grid.editor) { grid.editor = new App.grid.RowEditor({ formModel: grid.model.formModel, - table: grid.model.table, + table: grid.model.table }); grid.editor.init(grid); } - var toolbar = grid.getTopToolbar(); + toolbar = grid.getTopToolbar(); toolbar.add([{ text: 'Add', @@ -62,7 +64,7 @@ App.grid.RowEditorToolbar = Ext.extend(Object, { handler: grid.editor.onViewRow, scope: grid.editor }, '-']); - }, + } }); Ext.preg('pGridRowEditorToolbar', App.grid.RowEditorToolbar); diff --git a/static/plugin_dbui/lib/appjsonstore.js b/static/plugin_dbui/lib/appjsonstore.js index 82cdc71b..c921aa64 100644 --- a/static/plugin_dbui/lib/appjsonstore.js +++ b/static/plugin_dbui/lib/appjsonstore.js @@ -3,7 +3,7 @@ * Design to work with the class DbSvc on the server side. * * MANDATORY PROPERTIES: - * - model + * - model * * All configuration properties of Ext.data.Store are understood. * @@ -30,7 +30,7 @@ App.data.JsonWriter = Ext.extend(Ext.data.JsonWriter, { /** * constructor */ - constructor: function(config){ + constructor: function (config) { App.data.JsonWriter.superclass.constructor.call(this, config); }, /** @@ -43,13 +43,15 @@ App.data.JsonWriter = Ext.extend(Ext.data.JsonWriter, { * @param {Object} baseParams * @param {Object} data */ - render: function(params, baseParams, data){ + render: function (params, baseParams, data) { + var el, tmp; + // the baseParams contains many information to customize database actions. // Keep only information requires in write transaction - var tmp = Ext.apply({}, baseParams); - for (var el in baseParams){ - if (el != "table" && el != "debug"){ + tmp = Ext.apply({}, baseParams); + for (el in baseParams) { + if (el !== "table" && el !== "debug") { delete baseParams[el]; } } @@ -71,20 +73,23 @@ App.data.JsonWriter = Ext.extend(Ext.data.JsonWriter, { * @param {Object} response * @param {Object} args */ -App.data.httpException = function(dataproxy, type, action, options, response, args){ +App.data.httpException = function (dataproxy, type, action, options, response, args) { - if(response.status == 200){ + var dict, item, text = ''; + + if (response.status === 200) { // handle error coming from validation step on the server // decode the return json string - var dict = Ext.decode(response.responseText); + dict = Ext.decode(response.responseText); // build the error message - var text = new String(); - for(item in dict.errors){ - text += "Field <i>"+item+"</i>: "+dict.errors[item]+"<br>"; + for (item in dict.errors) { + if (dict.errors.hasOwnProperty(item)) { + text += "Field <i>" + item + "</i>: " + dict.errors[item] + "<br>"; + } } - text += "The record is not <i>"+action+"</i> in the database." + text += "The record is not <i>" + action + "</i> in the database."; // popup an alert Ext.MessageBox.show({ @@ -113,14 +118,14 @@ App.data.JsonStore = Ext.extend(Ext.data.Store, { /** * @cfg {Object} model Object to configure the store for a table of the database. * It is provided by the server and contains the following keys: - * { - * table: 'xx', - * fields: [field1, firld2,...], - * dbFields: [(table1, field1),...], - * where: [...], - * leftjoin: ? - * groupby: ? - * orderby: ? + * { + * table: 'xx', + * fields: [field1, firld2,...], + * dbFields: [(table1, field1),...], + * where: [...], + * leftjoin: ? + * groupby: ? + * orderby: ? * } */ model: null, @@ -133,13 +138,14 @@ App.data.JsonStore = Ext.extend(Ext.data.Store, { /** * The constructor */ - constructor: function(config){ - + constructor: function (config) { + var el; + Ext.apply(this, config); if (!this.model) { - throw new Error("the property model is missing !!!") + throw new Error("the property model is missing !!!"); } // Setup json reader if not defined in config @@ -150,7 +156,7 @@ App.data.JsonStore = Ext.extend(Ext.data.Store, { root: 'data', fields: this.model.fields, totalProperty: 'results', - idProperty: this.model.idProperty, + idProperty: this.model.idProperty }); } @@ -165,15 +171,15 @@ App.data.JsonStore = Ext.extend(Ext.data.Store, { // Setup the baseParams parameters // They are always send to the server and allows to steer the action // In fact copy the model except the fields property - for (var el in this.model){ - if (el != "fields") { + for (el in this.model) { + if (el !== "fields") { this.baseParams[el] = this.model[el]; } } // activate the debug mode - if (this.debug){ - this.baseParams["debug"] = true; + if (this.debug) { + this.baseParams.debug = true; } // add a listener to catch HTTP failure diff --git a/static/plugin_dbui/lib/appmgr.js b/static/plugin_dbui/lib/appmgr.js index 817d21f2..0ea0e4f8 100644 --- a/static/plugin_dbui/lib/appmgr.js +++ b/static/plugin_dbui/lib/appmgr.js @@ -14,9 +14,9 @@ * as well as the model for the xentry and xgrid widgets. * * The properties of App.Mgr allow to customize the application: - * - the list of tables visible - * - xentry and xgrid widgets - * - ... + * the list of tables visible + * xentry and xgrid widgets + * * * $Id$ * @@ -29,16 +29,21 @@ App.Mgr = Ext.extend(Object, { * constructor of the application manager * @param {Object} config */ - constructor: function(config){ + constructor: function (config) { Ext.apply(this, config); App.Mgr.superclass.constructor.apply(this); - App.withMathJax ? App.loadMathJax(this.configure, this) : this.configure(); + + if (App.withMathJax) { + App.loadMathJax(this.configure, this); + } else { + this.configure(); + } }, /** * Callback function to get the configuration from the server */ - configure: function(){ + configure: function () { cfgSvc.getTables(this.launch, this); }, /** @@ -52,41 +57,42 @@ App.Mgr = Ext.extend(Object, { * @param {Object} provider * @param {Object} response */ - launch: function(provider, response){ + launch: function (provider, response) { + + var cfg, formInTree, tableInTree, tables, viewport; // list of tables - var tables = response.result.tables; + tables = response.result.tables; /* * Plugin to handle entryForm */ - var formInTree = { + formInTree = { topNodeName: 'Forms', nodesId: tables, nodesText: response.result.tablesText, tabTitlePrefix: 'Form', - ptype: 'pInTreeForm', + ptype: 'pInTreeForm' }; /* * Plugin to handle grid - */ - var tableInTree = { + */ + tableInTree = { topNodeName: 'Tables', nodesId: tables, nodesText: response.result.tablesText, tabTitlePrefix: 'Table', - ptype: 'pInTreeGrid', + ptype: 'pInTreeGrid' }; /* * Pre-configured viewport with a treePanel and a tabPanel */ - - var cfg = Ext.apply({ - plugins: [formInTree, tableInTree], + cfg = Ext.apply({ + plugins: [formInTree, tableInTree] }, App.viewport.cfg.withTreeAndTabPanels); - var viewport= new Ext.Viewport (cfg); - }, + viewport = new Ext.Viewport(cfg); + } }); diff --git a/static/plugin_dbui/lib/apppanelmathjax.js b/static/plugin_dbui/lib/apppanelmathjax.js index 6512ccc9..071e2a5d 100644 --- a/static/plugin_dbui/lib/apppanelmathjax.js +++ b/static/plugin_dbui/lib/apppanelmathjax.js @@ -10,8 +10,8 @@ Ext.namespace('App.panel'); App.panel.MathJax = Ext.extend(Object, { - - init: function(panel){ + + init: function (panel) { // register an handler which is activated only once // when the panel is rendered for the first time @@ -24,7 +24,7 @@ App.panel.MathJax = Ext.extend(Object, { * * @param {Ext.Panel} panel */ - onPanelRender: function(panel){ + onPanelRender: function (panel) { var updater = panel.body.getUpdater(); updater.on('update', this.onProcess); }, @@ -34,10 +34,10 @@ App.panel.MathJax = Ext.extend(Object, { * @param {Ext.Element} el * @param {Object} o the response object */ - onProcess: function(e, o){ + onProcess: function (e, o) { MathJax.Hub.PreProcess(); MathJax.Hub.Process(); - }, + } }); Ext.preg('pPanelMathJax', App.panel.MathJax); \ No newline at end of file diff --git a/static/plugin_dbui/lib/appsetbox.js b/static/plugin_dbui/lib/appsetbox.js index 2216f619..9102f2a8 100644 --- a/static/plugin_dbui/lib/appsetbox.js +++ b/static/plugin_dbui/lib/appsetbox.js @@ -2,8 +2,8 @@ * A pre-configured combobox displaying a set of predefined value. * * MANDATORY PROPERTIES: - * - model - * + * - model + * * All configuration properties of Ext.form.ComboBox are understood. * * @extends Ext.form.ComboBox @@ -18,7 +18,7 @@ App.form.SetBox = Ext.extend(Ext.form.ComboBox, { /** * @cfg {Object} model Object to configure the widget. * It is provided by the server and contains the following keys: - * { setData: [...]} + * { setData: [...]} */ model: null, @@ -35,15 +35,17 @@ App.form.SetBox = Ext.extend(Ext.form.ComboBox, { /** * private method require by the ExtJs component model */ - initComponent: function(){ + initComponent: function () { - if (!this.model){ - throw new Error("the property model is missing !!!") + var i, li = []; + + if (!this.model) { + throw new Error("the property model is missing !!!"); } // setup the store - var li = []; - for (var i=0; i < this.model.setData.length; i++){ + li = []; + for (i = 0; i < this.model.setData.length; i += 1) { li.push([this.model.setData[i]]); } diff --git a/static/plugin_dbui/lib/appviewportcfg.js b/static/plugin_dbui/lib/appviewportcfg.js index b3d6f6e3..4465db4e 100644 --- a/static/plugin_dbui/lib/appviewportcfg.js +++ b/static/plugin_dbui/lib/appviewportcfg.js @@ -1,25 +1,25 @@ /** * Configuration files to defined an application viewport: * - * App.viewport.cfg.withTreeAndTabPanels: + * App.viewport.cfg.withTreeAndTabPanels: * - * A viewport with a tree panel and a tab panel. - * - * The tree panel is referenced as treePanel - * and the tab panel as tabPanel. These panels can therefore - * be accessed via the property this.treePanel .... - * + * A viewport with a tree panel and a tab panel. + * + * The tree panel is referenced as treePanel + * and the tab panel as tabPanel. These panels can therefore + * be accessed via the property this.treePanel .... + * * The name of the root node of the tree is App.name * It is not visible. - * - * The plugin App.viewport.InTreePanel can be used - * with this object. + * + * The plugin App.viewport.InTreePanel can be used + * with this object. * * @author legac * @version $Id$ */ -Ext.namespace('App.viewport.cfg'); +Ext.namespace('App.viewport.cfg'); App.viewport.cfg.withTreeAndTabPanels = { layout: 'border', @@ -36,15 +36,15 @@ App.viewport.cfg.withTreeAndTabPanels = { rootVisible: false, root: new Ext.tree.TreeNode({ id: App.name, - text: App.name, + text: App.name }), - ref: 'treePanel', + ref: 'treePanel' }, { region: 'center', xtype: 'tabpanel', ref: 'tabPanel', autoScroll: true, - defaults: {layout: 'fit'}, + defaults: {layout: 'fit'} } - ], + ] }; diff --git a/static/plugin_dbui/lib/appviewportintreebase.js b/static/plugin_dbui/lib/appviewportintreebase.js index 029dbf14..dfd73750 100644 --- a/static/plugin_dbui/lib/appviewportintreebase.js +++ b/static/plugin_dbui/lib/appviewportintreebase.js @@ -15,18 +15,18 @@ * See for example App.viewport.InTreePanelGrid. * * The ptype of this component is pInTreeBase. - * + * * MANDATORY PROPERTIES: - * - models - * - topNodeName - * - nodes + * - models + * - topNodeName + * - nodes * * NOTE ON NAMING CONVENTION: - * - the id of leaf node are defined as: - * /App.name/TopNodeName/node + * - the id of leaf node are defined as: + * /App.name/TopNodeName/node * - * - the id of create tab is equal to the id of the node: - * /App.name/TopNodeName/node + * - the id of create tab is equal to the id of the node: + * /App.name/TopNodeName/node * * @author legac * @version $Id$ @@ -77,7 +77,7 @@ App.viewport.InTreePanelBase = Ext.extend(Object, { * Constructor * @param {Object} config */ - constructor: function(config){ + constructor: function (config) { Ext.apply(this, config); App.viewport.InTreePanelBase.superclass.constructor.apply(this); }, @@ -86,31 +86,33 @@ App.viewport.InTreePanelBase = Ext.extend(Object, { * Plugin initialization function * @param {Ext.Viewport} viewport */ - init: function(viewport){ + init: function (viewport) { + var i, child, node, root; + this.viewport = viewport; // add the top node in the tree - var node = new Ext.tree.TreeNode({ - id: '/'+App.name+"/"+this.topNodeName, - text: this.topNodeName, + node = new Ext.tree.TreeNode({ + id: '/' + App.name + "/" + this.topNodeName, + text: this.topNodeName }); - var root = viewport.treePanel.getRootNode(); + root = viewport.treePanel.getRootNode(); root.appendChild(node); // nodesText if not specified - if (!this.nodesText){ + if (!this.nodesText) { this.nodesText = this.nodesId; } //add the children and the associated handler - for (var i = 0; i < this.nodesId.length; i++){ + for (i = 0; i < this.nodesId.length; i += 1) { - var child = new Ext.tree.TreeNode({ - id: "/"+App.name+"/"+this.topNodeName+"/"+this.nodesId[i], + child = new Ext.tree.TreeNode({ + id: "/" + App.name + "/" + this.topNodeName + "/" + this.nodesId[i], text: this.nodesText[i], - leaf: true, + leaf: true }); node.appendChild(child); @@ -127,15 +129,15 @@ App.viewport.InTreePanelBase = Ext.extend(Object, { * NOTE: This method is call when the beforeadd event is fired. * NOTE: the simplest function should contains * - * var wdg = new Ext....; - * component.add(wdg); - * component.doLayout(); + * var wdg = new Ext....; + * component.add(wdg); + * component.doLayout(); * * @param {Object} container the viewport.tabPanel * @param {Object} component the create tab/panel * @param {Integer} index the index of the tab */ - addWdg: function(container, component, index){}, + addWdg: function (container, component, index) {}, /** * Helper method to return the node name from the tab id @@ -144,7 +146,7 @@ App.viewport.InTreePanelBase = Ext.extend(Object, { * * @param {String} id */ - getNodeNameFromId: function(id){ + getNodeNameFromId: function (id) { var li = id.split("/").reverse(); return li[0]; }, @@ -156,7 +158,7 @@ App.viewport.InTreePanelBase = Ext.extend(Object, { * * @param {String} id */ - getTopNodeNameFromId: function(id){ + getTopNodeNameFromId: function (id) { var li = id.split("/").reverse(); return li[1]; }, @@ -167,29 +169,31 @@ App.viewport.InTreePanelBase = Ext.extend(Object, { * * @param {Object} node Ext.treeTreeNode */ - onCreateTab: function(node){ + onCreateTab: function (node) { + var pan, tab, tabId, table; + // is the tab already exists - var tabId = node.id; - if(this.viewport.tabPanel.getItem(tabId)){ + tabId = node.id; + if (this.viewport.tabPanel.getItem(tabId)) { this.viewport.tabPanel.setActiveTab(tabId); return; } // retrieve the name of the table from the tabId - var table = this.getNodeNameFromId(tabId); + table = this.getNodeNameFromId(tabId); // create a panel - var pan = new Ext.Panel({ + pan = new Ext.Panel({ id: tabId, closable: true, - title: this.tabTitlePrefix+" "+table, + title: this.tabTitlePrefix + " " + table }); - var tab = this.viewport.tabPanel.add(pan); + tab = this.viewport.tabPanel.add(pan); this.viewport.tabPanel.setActiveTab(tab.id); - }, + } }); Ext.preg('pInTreeBase', App.viewport.InTreePanelBase); \ No newline at end of file diff --git a/static/plugin_dbui/lib/appviewportintreeform.js b/static/plugin_dbui/lib/appviewportintreeform.js index c9a62b47..29c545c3 100644 --- a/static/plugin_dbui/lib/appviewportintreeform.js +++ b/static/plugin_dbui/lib/appviewportintreeform.js @@ -14,11 +14,11 @@ * to the form. * * The ptype of this component is pInTreeForm. - * + * * MANDATORY PROPERTIES: - * - models - * - topNodeName - * - nodes + * - models + * - topNodeName + * - nodes * * @author legac * @extend App.viewport.InTreePanelBase @@ -36,26 +36,29 @@ App.viewport.InTreePanelForm = Ext.extend(App.viewport.InTreePanelBase, { * @param {Object} component * @param {Object} index */ - addWdg: function(container, component, index){ + addWdg: function (container, component, index) { + var cfg, table, wdg; + // protection -- add widget when we are concern ! - if (this.getTopNodeNameFromId(component.id) != this.topNodeName){ + if (this.getTopNodeNameFromId(component.id) !== this.topNodeName) { return; } // get the name of the table from the tab id - var table = this.getNodeNameFromId(component.id); + table = this.getNodeNameFromId(component.id); // Ask the server the widget configuration and create it - cfgSvc.getFormModel(table, function(provider,response){ + cfgSvc.getFormModel(table, function (provider, response) { - var cfg = response.result; - var wdg = Ext.ComponentMgr.create(cfg); + cfg = response.result; + wdg = Ext.ComponentMgr.create(cfg); component.add(wdg); component.doLayout(); }, this); - }, + } }); + Ext.preg('pInTreeForm', App.viewport.InTreePanelForm); diff --git a/static/plugin_dbui/lib/appviewportintreegrid.js b/static/plugin_dbui/lib/appviewportintreegrid.js index 16e76322..1214b82f 100644 --- a/static/plugin_dbui/lib/appviewportintreegrid.js +++ b/static/plugin_dbui/lib/appviewportintreegrid.js @@ -14,11 +14,11 @@ * to the grid like plugins. * * The ptype of this component is pInTreeGrid. - * + * * MANDATORY PROPERTIES: - * - models - * - topNodeName - * - nodes + * - models + * - topNodeName + * - nodes * * @author legac * @extend App.viewport.InTreePanelBase @@ -36,36 +36,38 @@ App.viewport.InTreePanelGrid = Ext.extend(App.viewport.InTreePanelBase, { * @param {Object} component * @param {Object} index */ - addWdg: function(container, component, index){ + addWdg: function (container, component, index) { + var cfg, grid, gridfilter, table, wdg; + // protection -- add widget when we are concern ! - if (this.getTopNodeNameFromId(component.id) != this.topNodeName){ + if (this.getTopNodeNameFromId(component.id) !== this.topNodeName) { return; } // get the name of the table from the tab id - var table = this.getNodeNameFromId(component.id); + table = this.getNodeNameFromId(component.id); // Ask the server the widget configuration and create it - cfgSvc.getGridModel(table, function(provider,response){ + cfgSvc.getGridModel(table, function (provider, response) { - var cfg = response.result; - var wdg = Ext.ComponentMgr.create(cfg); + cfg = response.result; + wdg = Ext.ComponentMgr.create(cfg); - if('filterModel' in cfg.model){ + if ('filterModel' in cfg.model) { // instantiate the grid and the filter - var grid = wdg; - var gridfilter = Ext.ComponentMgr.create(cfg.model.filterModel); + grid = wdg; + gridfilter = Ext.ComponentMgr.create(cfg.model.filterModel); gridfilter.bind(grid); // embedded the grid and the filter in a panel - var wdg = new Ext.Panel({ + wdg = new Ext.Panel({ layout: 'border', border: false, items: [{ region: 'center', layout: 'fit', - items: [grid], + items: [grid] }, { region: 'east', layout: 'form', @@ -76,8 +78,8 @@ App.viewport.InTreePanelGrid = Ext.extend(App.viewport.InTreePanelBase, { items: [gridfilter], width: 300, split: true, - buttons: [{text: 'reset', ref: '../../resetButton'}], - }], + buttons: [{text: 'reset', ref: '../../resetButton'}] + }] }); // connect the reset button @@ -93,6 +95,7 @@ App.viewport.InTreePanelGrid = Ext.extend(App.viewport.InTreePanelBase, { component.doLayout(); }, this); - }, + } }); -Ext.preg('pInTreeGrid', App.viewport.InTreePanelGrid); + +Ext.preg('pInTreeGrid', App.viewport.InTreePanelGrid); \ No newline at end of file -- GitLab