From 7cfe57486e82d1ca306c878686af5b157714b4b9 Mon Sep 17 00:00:00 2001 From: Renaud Le Gac <renaud.legac@free.fr> Date: Sat, 15 Jan 2011 17:00:07 +0000 Subject: [PATCH] Replace tab by space to be compliant with jslint recomendation. --- static/plugin_dbui/lib/appbase.js | 18 +- static/plugin_dbui/lib/appcombobox.js | 104 ++-- static/plugin_dbui/lib/appform.js | 152 ++--- static/plugin_dbui/lib/appform2.js | 134 ++--- static/plugin_dbui/lib/appgrid.js | 194 +++--- static/plugin_dbui/lib/appgridfilter.js | 310 +++++----- static/plugin_dbui/lib/appgridmathjax.js | 16 +- static/plugin_dbui/lib/appgridpaging.js | 180 +++--- static/plugin_dbui/lib/appgridroweditor.js | 560 +++++++++--------- .../lib/appgridroweditorcontextmenu.js | 136 ++--- .../lib/appgridroweditortoolbar.js | 70 +-- static/plugin_dbui/lib/appjsonstore.js | 284 ++++----- static/plugin_dbui/lib/appmgr.js | 142 ++--- static/plugin_dbui/lib/apppanelmathjax.js | 48 +- static/plugin_dbui/lib/appsetbox.js | 84 +-- static/plugin_dbui/lib/appviewportcfg.js | 50 +- .../plugin_dbui/lib/appviewportintreebase.js | 310 +++++----- .../plugin_dbui/lib/appviewportintreeform.js | 58 +- .../plugin_dbui/lib/appviewportintreegrid.js | 120 ++-- 19 files changed, 1485 insertions(+), 1485 deletions(-) diff --git a/static/plugin_dbui/lib/appbase.js b/static/plugin_dbui/lib/appbase.js index e437d75f..449fbb1b 100644 --- a/static/plugin_dbui/lib/appbase.js +++ b/static/plugin_dbui/lib/appbase.js @@ -41,13 +41,13 @@ App.dburl = '/' + App.name + '/plugin_dbui/database'; */ App.cfgSvcMethods = { - "url": '/' + App.name + '/plugin_dbui/configuration', - "type": "remoting", - "actions": { - "cfgSvc": [{'name': 'getFormModel', 'len': 1}, - {'name': 'getGridModel', 'len': 1}, - {'name': 'getTables', 'len': 0}] - } + "url": '/' + App.name + '/plugin_dbui/configuration', + "type": "remoting", + "actions": { + "cfgSvc": [{'name': 'getFormModel', 'len': 1}, + {'name': 'getGridModel', 'len': 1}, + {'name': 'getTables', 'len': 0}] + } }; /** @@ -55,7 +55,7 @@ App.cfgSvcMethods = { * @param {Object} callback */ App.loadMathJax = function (callback, scope) { - var path = '/' + App.name + '/static/plugin_mathjax/MathJax.js'; - Ext.Loader.load([path], 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 699de074..25a93e4a 100644 --- a/static/plugin_dbui/lib/appcombobox.js +++ b/static/plugin_dbui/lib/appcombobox.js @@ -18,61 +18,61 @@ Ext.namespace('App.form'); 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} - * } - */ - model: null, - - /** - * Predefined setting - * - */ - mode: 'remote', - editable: false, - selectOnFocus: true, - triggerAction: 'all', - typeAhead: true, - - /** - * private method require by the ExtJs component model - */ - initComponent: function () { + /** + * @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} + * } + */ + model: null, + + /** + * Predefined setting + * + */ + mode: 'remote', + editable: false, + selectOnFocus: true, + triggerAction: 'all', + typeAhead: true, + + /** + * private method require by the ExtJs component model + */ + initComponent: function () { - // defined the empty text from the field label - if (this.fieldLabel && !this.emptyText) { - this.emptyText = "Select a " + this.fieldLabel + " ..."; - } + // defined the empty text from the field label + if (this.fieldLabel && !this.emptyText) { + this.emptyText = "Select a " + this.fieldLabel + " ..."; + } - // setup the store if not defined by the user - // the autoLoad property set at true is mandatory to - // set a value when the combobox is not yet expend - if (!this.store) { - - this.store = new App.data.JsonStore({ - url: App.dburl, - model: this.model.store, - debug: App.debug, - sortInfo: {field: this.displayField}, - autoLoad: true - }); - } + // setup the store if not defined by the user + // the autoLoad property set at true is mandatory to + // set a value when the combobox is not yet expend + if (!this.store) { + + this.store = new App.data.JsonStore({ + url: App.dburl, + model: this.model.store, + debug: App.debug, + sortInfo: {field: this.displayField}, + autoLoad: true + }); + } - // construct the underlying class. DON'T MOVE - App.form.ComboBox.superclass.initComponent.call(this); - - // This few lines are required to set a value - // when the combobox is not yet expend - this.store.on('load', function () { - this.setValue(this.getValue()); - }, this); - } + // construct the underlying class. DON'T MOVE + App.form.ComboBox.superclass.initComponent.call(this); + + // This few lines are required to set a value + // when the combobox is not yet expend + 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 975c9bbb..01a18466 100644 --- a/static/plugin_dbui/lib/appform.js +++ b/static/plugin_dbui/lib/appform.js @@ -22,84 +22,84 @@ Ext.namespace('App.form'); App.form.FormPanel = Ext.extend(Ext.form.FormPanel, { - /** - * Predefined setting - */ - autoScroll: true, - bodyStyle: 'padding:5px 5px 0', - buttons: [{ - text: 'Clear', - ref: '../buttonClear' - }, { - text: 'Create', - ref: '../buttonCreate' - }, { - text: 'Update', - ref: '../buttonUpdate', - hidden: true - }, { - text: 'Delete', - ref: '../buttonDelete', - hidden: true - }], - defaults: {anchor: '100%'}, - defaultType: 'textfield', - frame: true, - - /** - * private method require by the ExtJs component model - */ - initComponent: function () { - - function resetForm() { - this.reset(); - } - - // construct the underlying class. DON'T MOVE - App.form.FormPanel.superclass.initComponent.call(this); - - // reset the form - this.buttonClear.on('click', resetForm, this.getForm()); - }, + /** + * Predefined setting + */ + autoScroll: true, + bodyStyle: 'padding:5px 5px 0', + buttons: [{ + text: 'Clear', + ref: '../buttonClear' + }, { + text: 'Create', + ref: '../buttonCreate' + }, { + text: 'Update', + ref: '../buttonUpdate', + hidden: true + }, { + text: 'Delete', + ref: '../buttonDelete', + hidden: true + }], + defaults: {anchor: '100%'}, + defaultType: 'textfield', + frame: true, + + /** + * private method require by the ExtJs component model + */ + initComponent: function () { + + function resetForm() { + this.reset(); + } + + // construct the underlying class. DON'T MOVE + App.form.FormPanel.superclass.initComponent.call(this); + + // reset the form + this.buttonClear.on('click', resetForm, this.getForm()); + }, - /** - * Helper function to enable/disable all fields of the form - * @param {Object} bool - */ - setFieldsDisable: function (bool) { - var form, i; - form = this.getForm(); - for (i = 0; i < form.items.length; i += 1) { - form.items.itemAt(i).setDisabled(bool); - } - }, - - /** - * Show the delete button and hide the others - */ - showButtonDelete: function () { - this.buttonDelete.show(); - this.buttonCreate.hide(); - this.buttonUpdate.hide(); - }, + /** + * Helper function to enable/disable all fields of the form + * @param {Object} bool + */ + setFieldsDisable: function (bool) { + var form, i; + form = this.getForm(); + for (i = 0; i < form.items.length; i += 1) { + form.items.itemAt(i).setDisabled(bool); + } + }, + + /** + * Show the delete button and hide the others + */ + showButtonDelete: function () { + this.buttonDelete.show(); + this.buttonCreate.hide(); + this.buttonUpdate.hide(); + }, - /** - * Show the Create button and hide the others - */ - showButtonCreate: function () { - this.buttonDelete.hide(); - this.buttonCreate.show(); - this.buttonUpdate.hide(); - }, - - /** - * Show the Update button and hide the others - */ - showButtonUpdate: function () { - this.buttonDelete.hide(); - this.buttonCreate.hide(); - this.buttonUpdate.show(); - } + /** + * Show the Create button and hide the others + */ + showButtonCreate: function () { + this.buttonDelete.hide(); + this.buttonCreate.show(); + this.buttonUpdate.hide(); + }, + + /** + * Show the Update button and hide the others + */ + 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 ce20b6b6..b02ed41d 100644 --- a/static/plugin_dbui/lib/appform2.js +++ b/static/plugin_dbui/lib/appform2.js @@ -28,86 +28,86 @@ Ext.namespace('App.form'); App.form.setToolTip = function (c) { Ext.ToolTip({ target: c.getEl(), - title: c.fieldLabel, + 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' - * } - */ - model: null, - - /** - * private method require by the ExtJs component model - */ - initComponent: function () { + /** + * @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' + * } + */ + model: null, + + /** + * private method require by the ExtJs component model + */ + initComponent: function () { - var fields, field, i; - - 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 - // NOTE: it is mandatory to defined the url here. - this.items = this.model.items; - this.url = App.dburl; + // define the item and the url + // NOTE: it is mandatory to defined the url here. + this.items = this.model.items; + this.url = App.dburl; - App.form.EntryFormPanel.superclass.initComponent.call(this); - this.buttonCreate.on("click", this.onSubmit, this); - - // Add handler to display tool tip for each field - // Require the configuration parameter 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); - } - } - }, + App.form.EntryFormPanel.superclass.initComponent.call(this); + this.buttonCreate.on("click", this.onSubmit, this); + + // Add handler to display tool tip for each field + // Require the configuration parameter 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); + } + } + }, - /** - * Private handler to submit values in the database - */ - onSubmit: function () { + /** + * Private handler to submit values in the database + */ + onSubmit: function () { - function onFailure(form, action) { - if (action.response) { - if (action.response.status !== 200) { - Ext.MessageBox.alert('Error', action.response.responseText); - } - } - } - - this.getForm().submit({ - clientValidation: true, - url: this.url, - method: 'POST', - params: { - 'debug': App.debug, - 'table': this.model.table, - 'xaction': 'create' - }, - reset: true, - waitMsg: 'Saving Record...', - failure: onFailure - }); - } + function onFailure(form, action) { + if (action.response) { + if (action.response.status !== 200) { + Ext.MessageBox.alert('Error', action.response.responseText); + } + } + } + + this.getForm().submit({ + clientValidation: true, + url: this.url, + method: 'POST', + params: { + 'debug': App.debug, + 'table': this.model.table, + 'xaction': 'create' + }, + reset: true, + waitMsg: 'Saving Record...', + failure: onFailure + }); + } }); Ext.reg('xentry', App.form.EntryFormPanel); diff --git a/static/plugin_dbui/lib/appgrid.js b/static/plugin_dbui/lib/appgrid.js index f6744017..e566f686 100644 --- a/static/plugin_dbui/lib/appgrid.js +++ b/static/plugin_dbui/lib/appgrid.js @@ -14,109 +14,109 @@ Ext.namespace('App.grid'); 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' - * } - */ - model: null, - - /** - * pre-defined properties - */ - iconCls: 'silk-grid', - frame: false, - viewConfig: {forceFit: true}, + /** + * @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' + * } + */ + model: null, + + /** + * pre-defined properties + */ + iconCls: 'silk-grid', + frame: false, + viewConfig: {forceFit: true}, - /** - * private - * keep track of RowEditor set by the plugins like - * RowEditorToolBar, RowEditorContextMenu. - */ - editor: null, + /** + * private + * keep track of RowEditor set by the plugins like + * RowEditorToolBar, RowEditorContextMenu. + */ + editor: null, - /** - * private method requests by the component model of Extjs - */ - initComponent: function () { + /** + * private method requests by the component model of Extjs + */ + 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 + // grid title this.title = this.model.title; - - // the data store - this.store = new App.data.JsonStore({ - url: App.dburl, - model: this.model.store, - debug: App.debug - }); - - // the columns model - this.columns = this.model.colModel; + + // the data store + this.store = new App.data.JsonStore({ + url: App.dburl, + model: this.model.store, + debug: App.debug + }); + + // the columns model + this.columns = this.model.colModel; - // empty top toolbar/bottomnar - this.tbar = []; - - // empty Paging toolbar require by the plugins - this.bbar = new Ext.PagingToolbar(); - this.bbar.hide(); - - // initialize the underlying class. DON'T MOVE - App.grid.Grid.superclass.initComponent.call(this); - - this.on('beforerender', this.onBeforeRender); - }, - - /** - * Handler call before render. It is used to load the store - * - * NOTE: - * The way to load the store depends on the presence of the paging plugin. - * In this library the initialisation sequence start with the initComponent - * followed by the initialisation of the plugins followed by the render. - * - * @param {Object} grid - */ - onBeforeRender: function (grid) { - - var i, isPagingPlugin; - - // is the paging plugin ? - 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; - } - } - } - } - - // load the store - // NOTE: when the paging is in action, need to recuperate the - // 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 { - grid.store.load(); - } - return true; - } + // empty top toolbar/bottomnar + this.tbar = []; + + // empty Paging toolbar require by the plugins + this.bbar = new Ext.PagingToolbar(); + this.bbar.hide(); + + // initialize the underlying class. DON'T MOVE + App.grid.Grid.superclass.initComponent.call(this); + + this.on('beforerender', this.onBeforeRender); + }, + + /** + * Handler call before render. It is used to load the store + * + * NOTE: + * The way to load the store depends on the presence of the paging plugin. + * In this library the initialisation sequence start with the initComponent + * followed by the initialisation of the plugins followed by the render. + * + * @param {Object} grid + */ + onBeforeRender: function (grid) { + + var i, isPagingPlugin; + + // is the paging plugin ? + 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; + } + } + } + } + + // load the store + // NOTE: when the paging is in action, need to recuperate the + // 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 { + grid.store.load(); + } + return true; + } }); Ext.reg('xgrid', App.grid.Grid); diff --git a/static/plugin_dbui/lib/appgridfilter.js b/static/plugin_dbui/lib/appgridfilter.js index 595f6e74..ea0d23ed 100644 --- a/static/plugin_dbui/lib/appgridfilter.js +++ b/static/plugin_dbui/lib/appgridfilter.js @@ -12,167 +12,167 @@ Ext.namespace('App.grid'); App.grid.GridFilter = Ext.extend(Ext.form.FieldSet, { - /** - * Private - * Dictionary with additional where clause - */ - filterConditions: {}, - - /** - * Private - * Initial where clause - */ - initialFilterConditions: [], - - /** - * Private - * Reference to the paging toolbar - */ - pagingToolbar: null, + /** + * Private + * Dictionary with additional where clause + */ + filterConditions: {}, + + /** + * Private + * Initial where clause + */ + initialFilterConditions: [], + + /** + * Private + * Reference to the paging toolbar + */ + pagingToolbar: null, - /** - * Private - * a reference to the grid store - */ - store: null, - - /** - * Predefined setting - * - * NOTE: - * the enableKeyEvents is mandatory for Ext.form.TextField - */ - defaults: { - anchor: '100%', - enableKeyEvents: true - }, - - /** - * private method requests by the component model of Ext JS - */ - initComponent: function () { + /** + * Private + * a reference to the grid store + */ + store: null, + + /** + * Predefined setting + * + * NOTE: + * the enableKeyEvents is mandatory for Ext.form.TextField + */ + defaults: { + anchor: '100%', + enableKeyEvents: true + }, + + /** + * private method requests by the component model of Ext JS + */ + initComponent: function () { - var field, fields, i; - - // initialize the underlying class. - App.grid.GridFilter.superclass.initComponent.call(this); - - // associate handlers to fields - 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') { - field.on('select', this.onChange, this); - - } else { - // catch the key pressed enter for other fields - // wait that user finish to type to run the handler - field.on('keyup', this.onChange, this, {buffer: 500}); - } - } - }, - - /** - * Bind the grid filter to the grid - * @param {Ext.grid.GridPanel} grid - */ - bind: function (grid) { + var field, fields, i; + + // initialize the underlying class. + App.grid.GridFilter.superclass.initComponent.call(this); + + // associate handlers to fields + 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') { + field.on('select', this.onChange, this); + + } else { + // catch the key pressed enter for other fields + // wait that user finish to type to run the handler + field.on('keyup', this.onChange, this, {buffer: 500}); + } + } + }, + + /** + * Bind the grid filter to the grid + * @param {Ext.grid.GridPanel} grid + */ + bind: function (grid) { - var baseParams, i; - - this.store = grid.getStore(); - - // paging toolbar ? - if (grid.pagingInitialized) { - this.pagingToolbar = grid.getBottomToolbar(); - } - - // initial filter conditions - baseParams = this.store.baseParams; - for (i = 0; i < baseParams.where.length; i += 1) { - this.initialFilterConditions.push(baseParams.where[i]); - } - - }, + var baseParams, i; + + this.store = grid.getStore(); + + // paging toolbar ? + if (grid.pagingInitialized) { + this.pagingToolbar = grid.getBottomToolbar(); + } + + // initial filter conditions + baseParams = this.store.baseParams; + for (i = 0; i < baseParams.where.length; i += 1) { + this.initialFilterConditions.push(baseParams.where[i]); + } + + }, - /** - * Handler to catch a change in field value - */ - onChange: function (field) { - this.setupCondition(field); - }, + /** + * Handler to catch a change in field value + */ + onChange: function (field) { + this.setupCondition(field); + }, - /** - * Handler to reset the filter - */ - onReset: function () { - - var fields, i; - - // reset the field value - fields = this.findByType('field'); - for (i = 0; i < fields.length; i += 1) { - fields[i].reset(); - } - - // reset filter conditions - this.filterConditions = {}; - this.store.baseParams.where = this.initialFilterConditions; - - // update the store - this.updateStore(); - }, - - /** - * Setup condition - * @param {Ext.form.Field} - */ - setupCondition: function (field) { + /** + * Handler to reset the filter + */ + onReset: function () { + + var fields, i; + + // reset the field value + fields = this.findByType('field'); + for (i = 0; i < fields.length; i += 1) { + fields[i].reset(); + } + + // reset filter conditions + this.filterConditions = {}; + this.store.baseParams.where = this.initialFilterConditions; + + // update the store + this.updateStore(); + }, + + /** + * Setup condition + * @param {Ext.form.Field} + */ + setupCondition: function (field) { - var conditions = [], i, k, value, where; - - // get the field value and update the condition dictionary - value = field.getValue(); - where = field.name + " " + field.filterOperator + " '" + value + "'"; - - if (value === '') { - delete this.filterConditions[field.name]; - } else { - this.filterConditions[field.name] = where; - } - - // build the complete where clause - for (i = 0; i < this.initialFilterConditions.length; i += 1) { - conditions.push(this.initialFilterConditions[i]); - } - - for (k in this.filterConditions) { - if (this.filterConditions.hasOwnProperty(k)) { - conditions.push(this.filterConditions[k]); - } - } - - // push new condition in the where clause of the store - this.store.baseParams.where = conditions; - - // update the store - this.updateStore(); - }, - - /** - * private - * Helper function to load the store applying filter conditions - */ - updateStore: function () { - - if (this.pagingToolbar) { - this.pagingToolbar.doRefresh(); - } else { - this.store.load(); - } - } + var conditions = [], i, k, value, where; + + // get the field value and update the condition dictionary + value = field.getValue(); + where = field.name + " " + field.filterOperator + " '" + value + "'"; + + if (value === '') { + delete this.filterConditions[field.name]; + } else { + this.filterConditions[field.name] = where; + } + + // build the complete where clause + for (i = 0; i < this.initialFilterConditions.length; i += 1) { + conditions.push(this.initialFilterConditions[i]); + } + + for (k in this.filterConditions) { + if (this.filterConditions.hasOwnProperty(k)) { + conditions.push(this.filterConditions[k]); + } + } + + // push new condition in the where clause of the store + this.store.baseParams.where = conditions; + + // update the store + this.updateStore(); + }, + + /** + * private + * Helper function to load the store applying filter conditions + */ + updateStore: function () { + + if (this.pagingToolbar) { + this.pagingToolbar.doRefresh(); + } else { + this.store.load(); + } + } }); Ext.reg('xgridfilter', App.grid.GridFilter); \ No newline at end of file diff --git a/static/plugin_dbui/lib/appgridmathjax.js b/static/plugin_dbui/lib/appgridmathjax.js index ae957724..c37df364 100644 --- a/static/plugin_dbui/lib/appgridmathjax.js +++ b/static/plugin_dbui/lib/appgridmathjax.js @@ -11,14 +11,14 @@ Ext.namespace('App.grid'); App.grid.MathJax = Ext.extend(Object, { - init: function (grid) { + init: function (grid) { - grid.getView().on('refresh', function () { - MathJax.Hub.PreProcess(); - MathJax.Hub.Process(); - }); - - } + 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 68f4413e..30faabba 100644 --- a/static/plugin_dbui/lib/appgridpaging.js +++ b/static/plugin_dbui/lib/appgridpaging.js @@ -9,100 +9,100 @@ Ext.namespace('App.grid'); App.grid.Paging = Ext.extend(Object, { - /** - * Private parameter identifying the type of plugin - */ - ptype: 'pGridPaging', + /** + * Private parameter identifying the type of plugin + */ + ptype: 'pGridPaging', - /** - * Plugin intialisation - */ - init: function (grid) { + /** + * Plugin intialisation + */ + init: function (grid) { - var bbar; - - grid.pagingInitialized = false; - - // associate the bbar to the grid store - bbar = grid.getBottomToolbar(); - bbar.bindStore(grid.store); + var bbar; + + grid.pagingInitialized = false; + + // associate the bbar to the grid store + bbar = grid.getBottomToolbar(); + bbar.bindStore(grid.store); - // add the slider and the export button - bbar.add('-', - 'Rows per page', - { - xtype: 'slider', - plugins: new Ext.slider.Tip(), - listeners: { - changecomplete: this.onChangePageSize, - scope: bbar - }, - minValue: 1, - width: 100 - }, - '->', - { - xtype: 'button', - text: 'Export to CSV', - listeners: {click: this.onExport} - } - ); - - bbar.show(); - - // NOTE: when this plugin is used, the grid load the store - // with the first row only. The results contains the total - // number of records in the store. We used it to initialized - // properly the slider. - grid.store.on('load', this.onStoreLoad, grid); - - }, - - /** - * Handler to change the number of rows per page - */ - onChangePageSize: function (slider, newValue, thumb) { - var bbar = this; - bbar.pageSize = newValue; - bbar.moveFirst(); - }, - - /** - * Handler to export the grid content as a CSV file - */ - 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) { + // add the slider and the export button + bbar.add('-', + 'Rows per page', + { + xtype: 'slider', + plugins: new Ext.slider.Tip(), + listeners: { + changecomplete: this.onChangePageSize, + scope: bbar + }, + minValue: 1, + width: 100 + }, + '->', + { + xtype: 'button', + text: 'Export to CSV', + listeners: {click: this.onExport} + } + ); + + bbar.show(); + + // NOTE: when this plugin is used, the grid load the store + // with the first row only. The results contains the total + // number of records in the store. We used it to initialized + // properly the slider. + grid.store.on('load', this.onStoreLoad, grid); + + }, + + /** + * Handler to change the number of rows per page + */ + onChangePageSize: function (slider, newValue, thumb) { + var bbar = this; + bbar.pageSize = newValue; + bbar.moveFirst(); + }, + + /** + * Handler to export the grid content as a CSV file + */ + 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) { - var bbar, grid = this, nRows = 10, slider; - - if (grid.pagingInitialized) { - return; - } - - grid.pagingInitialized = true; - - 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 !! - - slider.maxValue = store.totalLength; - slider.setValue(nRows); - - bbar.pageSize = nRows; - bbar.moveFirst(); - } - + var bbar, grid = this, nRows = 10, slider; + + if (grid.pagingInitialized) { + return; + } + + grid.pagingInitialized = true; + + 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 !! + + slider.maxValue = store.totalLength; + slider.setValue(nRows); + + bbar.pageSize = nRows; + bbar.moveFirst(); + } + }); Ext.preg('pGridPaging', App.grid.Paging); diff --git a/static/plugin_dbui/lib/appgridroweditor.js b/static/plugin_dbui/lib/appgridroweditor.js index bb5ce113..d412b551 100644 --- a/static/plugin_dbui/lib/appgridroweditor.js +++ b/static/plugin_dbui/lib/appgridroweditor.js @@ -23,310 +23,310 @@ Ext.namespace('App.grid'); App.grid.RowEditor = Ext.extend(Ext.Window, { - /** - * @cfg {Object} formModel a dictionary defining the form - * embedded in the window. Provide by the server. - */ - formModel: null, - - /** - * Private parameter identifying the type of plugin - */ - ptype: 'pgridroweditor', - - /** - * pre-defined properties for the window - */ - autoScroll: true, - closeAction: 'hide', - constrainHeader: true, - defaults: {autoScroll: true}, - modal: true, - plain: true, - - /** - * private method request by the EXtJs component model - */ - initComponent: function () { - - // create the FormPanel embedded in the window - this.items = [this.formModel]; - - App.grid.RowEditor.superclass.initComponent.call(this); - }, - - /** - * Plugin initialization - * - * @param {Object} grid GridPanel the grid instantiating the plugin - */ - init: function (grid) { - - var cbrec, combo, combos, i, item, values; - - function onUpdateStore(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]; - } - } - - 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); - } - } - } - - this.grid = grid; - this.formPanel = this.items.first(); - - // The grid keeps track of the editor - grid.editor = this; - - // The user can only select one row of the grid - this.grid.selModel = new Ext.grid.RowSelectionModel({ - singleSelect: true - }); - - // Switch off the autoSave mode of the store - // action on the store required the used the method save - // in order to commit the change - this.grid.store.autoSave = false; - - // Add a listener to hide the window, clear the form - // when the transaction with the database is successful - this.grid.store.on("save", this.endEdit, this); - - // 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", onUpdateStore, this); - }, - - /** - * Private function to add a row in the grid using form values - * The scope of this function is the App.grid.RowEditor - */ - addRowFromForm: function () { - - var i, rec, record; - - // Returns true if client-side validation on the form is successful. - 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 - 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 + /** + * @cfg {Object} formModel a dictionary defining the form + * embedded in the window. Provide by the server. + */ + formModel: null, + + /** + * Private parameter identifying the type of plugin + */ + ptype: 'pgridroweditor', + + /** + * pre-defined properties for the window + */ + autoScroll: true, + closeAction: 'hide', + constrainHeader: true, + defaults: {autoScroll: true}, + modal: true, + plain: true, + + /** + * private method request by the EXtJs component model + */ + initComponent: function () { + + // create the FormPanel embedded in the window + this.items = [this.formModel]; + + App.grid.RowEditor.superclass.initComponent.call(this); + }, + + /** + * Plugin initialization + * + * @param {Object} grid GridPanel the grid instantiating the plugin + */ + init: function (grid) { + + var cbrec, combo, combos, i, item, values; + + function onUpdateStore(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]; + } + } + + 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); + } + } + } + + this.grid = grid; + this.formPanel = this.items.first(); + + // The grid keeps track of the editor + grid.editor = this; + + // The user can only select one row of the grid + this.grid.selModel = new Ext.grid.RowSelectionModel({ + singleSelect: true + }); + + // Switch off the autoSave mode of the store + // action on the store required the used the method save + // in order to commit the change + this.grid.store.autoSave = false; + + // Add a listener to hide the window, clear the form + // when the transaction with the database is successful + this.grid.store.on("save", this.endEdit, this); + + // 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", onUpdateStore, this); + }, + + /** + * Private function to add a row in the grid using form values + * The scope of this function is the App.grid.RowEditor + */ + addRowFromForm: function () { + + var i, rec, record; + + // Returns true if client-side validation on the form is successful. + 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 + 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 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(); - }, - - /** - * Private method to update an existing row using form values - * The scope of this function is the App.grid.RowEditor - */ - editRowFromForm: function () { - - var record; - - // Returns true if client-side validation on the form is successful. - 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 - record = this.getSelected(); - this.updateRecord(record); - - // save the change in the database - this.grid.store.save(); - }, - - /** - * Private function call when the transaction with the database - * is successful. A transaction correspond to the action add, insert - * destroy and save. - * - * @param {Object} store - * @param {Object} batch - * @param {Object} data - */ - endEdit: function (store, batch, data) { - - // clear the form panel - this.formPanel.getForm().reset(); - - // hide the window - this.hide(); - }, - - /** - * Private method to return the record - * associate to the row selected in the grid - * - * In absence of selected row a warning message is shown - * and the function return false. - */ - getSelected: function () { + i = this.grid.store.indexOf(rec); + this.grid.store.insert(i + 1, record); + + // save the change in the database + this.grid.store.save(); + }, + + /** + * Private method to update an existing row using form values + * The scope of this function is the App.grid.RowEditor + */ + editRowFromForm: function () { + + var record; + + // Returns true if client-side validation on the form is successful. + 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 + record = this.getSelected(); + this.updateRecord(record); + + // save the change in the database + this.grid.store.save(); + }, + + /** + * Private function call when the transaction with the database + * is successful. A transaction correspond to the action add, insert + * destroy and save. + * + * @param {Object} store + * @param {Object} batch + * @param {Object} data + */ + endEdit: function (store, batch, data) { + + // clear the form panel + this.formPanel.getForm().reset(); + + // hide the window + this.hide(); + }, + + /** + * Private method to return the record + * associate to the row selected in the grid + * + * In absence of selected row a warning message is shown + * and the function return false. + */ + getSelected: function () { var rec = this.grid.getSelectionModel().getSelected(); if (!rec) { - Ext.MessageBox.alert('Warning', 'Select a row please'); + Ext.MessageBox.alert('Warning', 'Select a row please'); return false; } - return rec; - }, - - /** - * Handler to add a new row. - * The scope use by the handler is defined by the caller. - * It has to be the equal to the plugin object. - * - */ - onAddRow: function () { - - this.setTitle("Create a new record..."); - this.show(); - - this.formPanel.showButtonCreate(); - this.formPanel.buttonCreate.on("click", this.addRowFromForm, this); - }, - - /** - * Handler to delete the selected row - * The scope use by the handler is defined by the caller - * It has to be the equal to the plugin object. - * - */ - onDeleteRow: function () { + return rec; + }, + + /** + * Handler to add a new row. + * The scope use by the handler is defined by the caller. + * It has to be the equal to the plugin object. + * + */ + onAddRow: function () { + + this.setTitle("Create a new record..."); + this.show(); + + this.formPanel.showButtonCreate(); + this.formPanel.buttonCreate.on("click", this.addRowFromForm, this); + }, + + /** + * Handler to delete the selected row + * The scope use by the handler is defined by the caller + * It has to be the equal to the plugin object. + * + */ + onDeleteRow: function () { var record = this.getSelected(); if (!record) {return; } - this.grid.store.remove(record); - this.grid.store.save(); - }, + this.grid.store.remove(record); + this.grid.store.save(); + }, - /** - * Handler to duplicate the selected row - * The scope use by the handler is defined by the caller - * It has to be the equal to the plugin object. - * - */ - onDuplicateRow: function () { + /** + * Handler to duplicate the selected row + * The scope use by the handler is defined by the caller + * It has to be the equal to the plugin object. + * + */ + onDuplicateRow: function () { var record = this.getSelected(); if (!record) {return; } - this.setTitle("Duplicate the record..."); - this.show(); + this.setTitle("Duplicate the record..."); + this.show(); - this.formPanel.showButtonCreate(); - this.formPanel.getForm().loadRecord(record); - this.formPanel.buttonCreate.on("click", this.addRowFromForm, this); - }, + this.formPanel.showButtonCreate(); + this.formPanel.getForm().loadRecord(record); + this.formPanel.buttonCreate.on("click", this.addRowFromForm, this); + }, - /** - * Handler to edit the selected row. - * The scope use by the handler is defined by the caller. - * It has to be the equal to the plugin object. - * - */ - onEditRow: function () { + /** + * Handler to edit the selected row. + * The scope use by the handler is defined by the caller. + * It has to be the equal to the plugin object. + * + */ + onEditRow: function () { var record = this.getSelected(); if (!record) {return; } - this.setTitle("Update the record..."); - this.show(); - - this.formPanel.showButtonUpdate(); - this.formPanel.getForm().loadRecord(record); - this.formPanel.buttonUpdate.on("click", this.editRowFromForm, this); - }, - - /** - * Handler to view the selected row in the form. - * The scope use by the handler is defined by the caller. - * It has to be the equal to the plugin object. - * - * Field values are not modifiable. - * Interactions with the database are switch off. - * - */ - onViewRow: function () { - - var record; - - function onHide() { - this.formPanel.buttonClear.show(); - this.formPanel.buttonCreate.show(); - } - + this.setTitle("Update the record..."); + this.show(); + + this.formPanel.showButtonUpdate(); + this.formPanel.getForm().loadRecord(record); + this.formPanel.buttonUpdate.on("click", this.editRowFromForm, this); + }, + + /** + * Handler to view the selected row in the form. + * The scope use by the handler is defined by the caller. + * It has to be the equal to the plugin object. + * + * Field values are not modifiable. + * Interactions with the database are switch off. + * + */ + onViewRow: function () { + + var record; + + function onHide() { + this.formPanel.buttonClear.show(); + this.formPanel.buttonCreate.show(); + } + record = this.getSelected(); - if (!record) {return; } - - this.setTitle("View the record..."); - this.show(); - - this.formPanel.showButtonCreate(); - this.formPanel.getForm().loadRecord(record); - this.formPanel.buttonClear.hide(); - this.formPanel.buttonCreate.hide(); - - this.on("hide", onHide, this); - - }, - - /** - * Private function to update the selected record with the value of the form - * @param {Object} record - */ - updateRecord: function (record) { - - var combo, combos, i, item, rec, values; - - // Recuperate all values from the form - 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 - 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)); - } - - } + if (!record) {return; } + + this.setTitle("View the record..."); + this.show(); + + this.formPanel.showButtonCreate(); + this.formPanel.getForm().loadRecord(record); + this.formPanel.buttonClear.hide(); + this.formPanel.buttonCreate.hide(); + + this.on("hide", onHide, this); + + }, + + /** + * Private function to update the selected record with the value of the form + * @param {Object} record + */ + updateRecord: function (record) { + + var combo, combos, i, item, rec, values; + + // Recuperate all values from the form + 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 + 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)); + } + + } }); Ext.preg('pgridroweditor', App.grid.RowEditor); \ No newline at end of file diff --git a/static/plugin_dbui/lib/appgridroweditorcontextmenu.js b/static/plugin_dbui/lib/appgridroweditorcontextmenu.js index b81904e9..8aa4c81b 100644 --- a/static/plugin_dbui/lib/appgridroweditorcontextmenu.js +++ b/static/plugin_dbui/lib/appgridroweditorcontextmenu.js @@ -15,92 +15,92 @@ Ext.namespace('App.grid'); App.grid.RowEditorContextMenu = Ext.extend(Object, { - /** - * Private parameter identifying the type of plugin - */ - ptype: 'pGridRowEditorContextMenu', - - /** - * Plugin intialisation - * @param {Object} grid - */ - init: function (grid) { - - var menu = new Ext.menu.Menu(); - - // create and initialize the underlying RowEditor - if (!grid.editor) { - grid.editor = new App.grid.RowEditor({ - formModel: grid.model.formModel, - table: grid.model.table - }); - - grid.editor.init(grid); - } + /** + * Private parameter identifying the type of plugin + */ + ptype: 'pGridRowEditorContextMenu', + + /** + * Plugin intialisation + * @param {Object} grid + */ + init: function (grid) { + + var menu = new Ext.menu.Menu(); + + // create and initialize the underlying RowEditor + if (!grid.editor) { + grid.editor = new App.grid.RowEditor({ + formModel: grid.model.formModel, + table: grid.model.table + }); + + grid.editor.init(grid); + } - grid.addListener('containercontextmenu', this.onContainerContextMenu, menu); - grid.addListener('headercontextmenu', this.onHeaderContextMenu, menu); - grid.addListener('rowcontextmenu', this.onRowContextMenu, menu); - - menu.add({ + grid.addListener('containercontextmenu', this.onContainerContextMenu, menu); + grid.addListener('headercontextmenu', this.onHeaderContextMenu, menu); + grid.addListener('rowcontextmenu', this.onRowContextMenu, menu); + + menu.add({ text: 'Add', iconCls: 'silk-add', handler: grid.editor.onAddRow, - scope: grid.editor + scope: grid.editor }, '-', { text: 'Delete', iconCls: 'silk-delete', handler: grid.editor.onDeleteRow, - scope: grid.editor - }, '-', { - text: 'Duplicate', + scope: grid.editor + }, '-', { + text: 'Duplicate', iconCls: 'silk-clone', handler: grid.editor.onDuplicateRow, - scope: grid.editor - }, { + scope: grid.editor + }, { text: 'Update', iconCls: 'silk-update', handler: grid.editor.onEditRow, - scope: grid.editor - }, '-', { + scope: grid.editor + }, '-', { text: 'View', iconCls: 'silk-view', handler: grid.editor.onViewRow, - scope: grid.editor + scope: grid.editor }); - }, - - /** - * Handler displaying the row context menu in an empty grid - */ - onContainerContextMenu: function (grid, event) { - var menu = this; - - event.stopEvent(); - menu.showAt(event.getXY()); - - }, - /** - * Handler displaying the context menu in the header - * Nothing is display in that case. - */ - onHeaderContextMenu: function (grid, columIndex, event) { - event.stopEvent(); - }, - /** - * handler displaying the row context menu - * 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) { - - var menu = this; - - event.stopEvent(); - grid.selModel.selectRow(rowIndex); - menu.showAt(event.getXY()); + }, + + /** + * Handler displaying the row context menu in an empty grid + */ + onContainerContextMenu: function (grid, event) { + var menu = this; + + event.stopEvent(); + menu.showAt(event.getXY()); + + }, + /** + * Handler displaying the context menu in the header + * Nothing is display in that case. + */ + onHeaderContextMenu: function (grid, columIndex, event) { + event.stopEvent(); + }, + /** + * handler displaying the row context menu + * 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) { + + var menu = this; + + event.stopEvent(); + 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 74ce2b67..83045f79 100644 --- a/static/plugin_dbui/lib/appgridroweditortoolbar.js +++ b/static/plugin_dbui/lib/appgridroweditortoolbar.js @@ -13,58 +13,58 @@ Ext.namespace('App.grid'); App.grid.RowEditorToolbar = Ext.extend(Object, { - /** - * Private parameter identifying the type of plugin - */ - ptype: 'pGridRowEditorToolbar', - - /** - * Plugin intiaisation - * @param {Object} grid - */ - init: function (grid) { + /** + * Private parameter identifying the type of plugin + */ + ptype: 'pGridRowEditorToolbar', + + /** + * Plugin intiaisation + * @param {Object} grid + */ + init: function (grid) { - var toolbar; - - // create and initialize the underlying RowEditor - if (!grid.editor) { - grid.editor = new App.grid.RowEditor({ - formModel: grid.model.formModel, - table: grid.model.table - }); - - grid.editor.init(grid); - } - - toolbar = grid.getTopToolbar(); - - toolbar.add([{ + var toolbar; + + // create and initialize the underlying RowEditor + if (!grid.editor) { + grid.editor = new App.grid.RowEditor({ + formModel: grid.model.formModel, + table: grid.model.table + }); + + grid.editor.init(grid); + } + + toolbar = grid.getTopToolbar(); + + toolbar.add([{ text: 'Add', iconCls: 'silk-add', handler: grid.editor.onAddRow, - scope: grid.editor + scope: grid.editor }, ' ', { text: 'Delete', iconCls: 'silk-delete', handler: grid.editor.onDeleteRow, - scope: grid.editor - }, ' ', { - text: 'Duplicate', + scope: grid.editor + }, ' ', { + text: 'Duplicate', iconCls: 'silk-clone', handler: grid.editor.onDuplicateRow, - scope: grid.editor - }, ' ', { + scope: grid.editor + }, ' ', { text: 'Update', iconCls: 'silk-update', handler: grid.editor.onEditRow, - scope: grid.editor - }, ' ', { + scope: grid.editor + }, ' ', { text: 'View', iconCls: 'silk-view', handler: grid.editor.onViewRow, - scope: grid.editor + 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 c921aa64..231957b2 100644 --- a/static/plugin_dbui/lib/appjsonstore.js +++ b/static/plugin_dbui/lib/appjsonstore.js @@ -22,46 +22,46 @@ Ext.namespace('App.data'); * */ App.data.JsonWriter = Ext.extend(Ext.data.JsonWriter, { - /** - * Pre-defined properties - */ - encode: true, - encodeDelete: true, - /** - * constructor - */ - constructor: function (config) { - App.data.JsonWriter.superclass.constructor.call(this, config); - }, - /** - * The render function finalizes the params object. - * In the base class, this method copies the baseParams and the data. - * Addapt the base class method to remove the baseParams which are not - * used by the server for the write actions - * - * @param {Object} params - * @param {Object} baseParams - * @param {Object} 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 - tmp = Ext.apply({}, baseParams); - for (el in baseParams) { - if (el !== "table" && el !== "debug") { - delete baseParams[el]; - } - } - - // execute the underlying method - App.data.JsonWriter.superclass.render.apply(this, arguments); - - // restore the baseParams for later use - Ext.apply(baseParams, tmp); - } + /** + * Pre-defined properties + */ + encode: true, + encodeDelete: true, + /** + * constructor + */ + constructor: function (config) { + App.data.JsonWriter.superclass.constructor.call(this, config); + }, + /** + * The render function finalizes the params object. + * In the base class, this method copies the baseParams and the data. + * Addapt the base class method to remove the baseParams which are not + * used by the server for the write actions + * + * @param {Object} params + * @param {Object} baseParams + * @param {Object} 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 + tmp = Ext.apply({}, baseParams); + for (el in baseParams) { + if (el !== "table" && el !== "debug") { + delete baseParams[el]; + } + } + + // execute the underlying method + App.data.JsonWriter.superclass.render.apply(this, arguments); + + // restore the baseParams for later use + Ext.apply(baseParams, tmp); + } }); /** @@ -74,39 +74,39 @@ App.data.JsonWriter = Ext.extend(Ext.data.JsonWriter, { * @param {Object} args */ App.data.httpException = function (dataproxy, type, action, options, response, args) { - - var dict, item, text = ''; - - if (response.status === 200) { - - // handle error coming from validation step on the server - // decode the return json string - dict = Ext.decode(response.responseText); - - // build the error message - 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."; - - // popup an alert - Ext.MessageBox.show({ - title: "DATABASE ERROR", - msg: text, - buttons: Ext.MessageBox.OK, - icon: Ext.MessageBox.ERROR - }); - } else { - // handle all other king of errors - Ext.MessageBox.show({ - title: response.statusText, - msg: response.responseText, - buttons: Ext.MessageBox.OK, - icon: Ext.MessageBox.ERROR - }); - } + + var dict, item, text = ''; + + if (response.status === 200) { + + // handle error coming from validation step on the server + // decode the return json string + dict = Ext.decode(response.responseText); + + // build the error message + 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."; + + // popup an alert + Ext.MessageBox.show({ + title: "DATABASE ERROR", + msg: text, + buttons: Ext.MessageBox.OK, + icon: Ext.MessageBox.ERROR + }); + } else { + // handle all other king of errors + Ext.MessageBox.show({ + title: response.statusText, + msg: response.responseText, + buttons: Ext.MessageBox.OK, + icon: Ext.MessageBox.ERROR + }); + } }; @@ -115,74 +115,74 @@ App.data.httpException = function (dataproxy, type, action, options, response, a */ 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: ? - * } - */ - model: null, - /** - * - * @cfg {Boolean} debug (optional) avtivate the debug mode - */ - debug: false, - - /** - * The constructor - */ - constructor: function (config) { - - var el; - - Ext.apply(this, config); - - if (!this.model) { - throw new Error("the property model is missing !!!"); - } + /** + * @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: ? + * } + */ + model: null, + /** + * + * @cfg {Boolean} debug (optional) avtivate the debug mode + */ + debug: false, + + /** + * The constructor + */ + constructor: function (config) { + + var el; + + Ext.apply(this, config); + + if (!this.model) { + throw new Error("the property model is missing !!!"); + } - // Setup json reader if not defined in config - // Assume that we are reading data coming from a single table. - if (!config.reader) { - - this.reader = new Ext.data.JsonReader({ - root: 'data', - fields: this.model.fields, - totalProperty: 'results', - idProperty: this.model.idProperty - }); - } - - // Setup the json writer if not defined in config - if (!config.writer) { - this.writer = new App.data.JsonWriter(); - } - - // construct the underlying class. DON'T MOVE - App.data.JsonStore.superclass.constructor.apply(this); - - // 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 (el in this.model) { - if (el !== "fields") { - this.baseParams[el] = this.model[el]; - } - } - - // activate the debug mode - if (this.debug) { - this.baseParams.debug = true; - } - - // add a listener to catch HTTP failure - this.addListener('exception', App.data.httpException); - } + // Setup json reader if not defined in config + // Assume that we are reading data coming from a single table. + if (!config.reader) { + + this.reader = new Ext.data.JsonReader({ + root: 'data', + fields: this.model.fields, + totalProperty: 'results', + idProperty: this.model.idProperty + }); + } + + // Setup the json writer if not defined in config + if (!config.writer) { + this.writer = new App.data.JsonWriter(); + } + + // construct the underlying class. DON'T MOVE + App.data.JsonStore.superclass.constructor.apply(this); + + // 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 (el in this.model) { + if (el !== "fields") { + this.baseParams[el] = this.model[el]; + } + } + + // activate the debug mode + if (this.debug) { + this.baseParams.debug = true; + } + + // add a listener to catch HTTP failure + this.addListener('exception', App.data.httpException); + } }); diff --git a/static/plugin_dbui/lib/appmgr.js b/static/plugin_dbui/lib/appmgr.js index 0ea0e4f8..9fb0c013 100644 --- a/static/plugin_dbui/lib/appmgr.js +++ b/static/plugin_dbui/lib/appmgr.js @@ -24,75 +24,75 @@ Ext.namespace('App'); App.Mgr = Ext.extend(Object, { - - /** - * constructor of the application manager - * @param {Object} config - */ - constructor: function (config) { - Ext.apply(this, config); - App.Mgr.superclass.constructor.apply(this); - - if (App.withMathJax) { - App.loadMathJax(this.configure, this); - } else { - this.configure(); - } - }, - - /** - * Callback function to get the configuration from the server - */ - configure: function () { - cfgSvc.getTables(this.launch, this); - }, - /** - * Call back function to launch the application. - * The response should have the property result. - * It contains the list of tables available for this web application - * - * This method is compatible with the Ext.Direct protocol - * http://www.extjs.com/products/extjs/direct.php - * - * @param {Object} provider - * @param {Object} response - */ - launch: function (provider, response) { - - var cfg, formInTree, tableInTree, tables, viewport; - - // list of tables - tables = response.result.tables; - - /* - * Plugin to handle entryForm - */ - formInTree = { - topNodeName: 'Forms', - nodesId: tables, - nodesText: response.result.tablesText, - tabTitlePrefix: 'Form', - ptype: 'pInTreeForm' - }; - - /* - * Plugin to handle grid - */ - tableInTree = { - topNodeName: 'Tables', - nodesId: tables, - nodesText: response.result.tablesText, - tabTitlePrefix: 'Table', - ptype: 'pInTreeGrid' - }; - - /* - * Pre-configured viewport with a treePanel and a tabPanel - */ - cfg = Ext.apply({ - plugins: [formInTree, tableInTree] - }, App.viewport.cfg.withTreeAndTabPanels); - - viewport = new Ext.Viewport(cfg); - } + + /** + * constructor of the application manager + * @param {Object} config + */ + constructor: function (config) { + Ext.apply(this, config); + App.Mgr.superclass.constructor.apply(this); + + if (App.withMathJax) { + App.loadMathJax(this.configure, this); + } else { + this.configure(); + } + }, + + /** + * Callback function to get the configuration from the server + */ + configure: function () { + cfgSvc.getTables(this.launch, this); + }, + /** + * Call back function to launch the application. + * The response should have the property result. + * It contains the list of tables available for this web application + * + * This method is compatible with the Ext.Direct protocol + * http://www.extjs.com/products/extjs/direct.php + * + * @param {Object} provider + * @param {Object} response + */ + launch: function (provider, response) { + + var cfg, formInTree, tableInTree, tables, viewport; + + // list of tables + tables = response.result.tables; + + /* + * Plugin to handle entryForm + */ + formInTree = { + topNodeName: 'Forms', + nodesId: tables, + nodesText: response.result.tablesText, + tabTitlePrefix: 'Form', + ptype: 'pInTreeForm' + }; + + /* + * Plugin to handle grid + */ + tableInTree = { + topNodeName: 'Tables', + nodesId: tables, + nodesText: response.result.tablesText, + tabTitlePrefix: 'Table', + ptype: 'pInTreeGrid' + }; + + /* + * Pre-configured viewport with a treePanel and a tabPanel + */ + cfg = Ext.apply({ + plugins: [formInTree, tableInTree] + }, App.viewport.cfg.withTreeAndTabPanels); + + viewport = new Ext.Viewport(cfg); + } }); diff --git a/static/plugin_dbui/lib/apppanelmathjax.js b/static/plugin_dbui/lib/apppanelmathjax.js index 071e2a5d..30918bd1 100644 --- a/static/plugin_dbui/lib/apppanelmathjax.js +++ b/static/plugin_dbui/lib/apppanelmathjax.js @@ -11,33 +11,33 @@ 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 - panel.on('render', this.onPanelRender, this, {single: true}); - }, + // register an handler which is activated only once + // when the panel is rendered for the first time + panel.on('render', this.onPanelRender, this, {single: true}); + }, - /** - * Handler to activates the MathJax processing - * when the html content of the panel is loaded. - * - * @param {Ext.Panel} panel - */ - onPanelRender: function (panel) { - var updater = panel.body.getUpdater(); - updater.on('update', this.onProcess); - }, + /** + * Handler to activates the MathJax processing + * when the html content of the panel is loaded. + * + * @param {Ext.Panel} panel + */ + onPanelRender: function (panel) { + var updater = panel.body.getUpdater(); + updater.on('update', this.onProcess); + }, - /** - * Handler to run the mathJax processing - * @param {Ext.Element} el - * @param {Object} o the response object - */ - onProcess: function (e, o) { - MathJax.Hub.PreProcess(); - MathJax.Hub.Process(); - } + /** + * Handler to run the mathJax processing + * @param {Ext.Element} el + * @param {Object} o the response object + */ + 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 9102f2a8..f824d4cb 100644 --- a/static/plugin_dbui/lib/appsetbox.js +++ b/static/plugin_dbui/lib/appsetbox.js @@ -15,53 +15,53 @@ Ext.namespace('App.form'); 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: [...]} - */ - model: null, + /** + * @cfg {Object} model Object to configure the widget. + * It is provided by the server and contains the following keys: + * { setData: [...]} + */ + model: null, - /** - * Predefined setting - * - */ - editable: false, - emptyText: "Select...", - selectOnFocus: true, - triggerAction: 'all', - typeAhead: true, - - /** - * private method require by the ExtJs component model - */ - initComponent: function () { + /** + * Predefined setting + * + */ + editable: false, + emptyText: "Select...", + selectOnFocus: true, + triggerAction: 'all', + typeAhead: true, + + /** + * private method require by the ExtJs component model + */ + initComponent: function () { - var i, li = []; - - if (!this.model) { - throw new Error("the property model is missing !!!"); - } - - // setup the store - li = []; - for (i = 0; i < this.model.setData.length; i += 1) { - li.push([this.model.setData[i]]); - } + var i, li = []; + + if (!this.model) { + throw new Error("the property model is missing !!!"); + } + + // setup the store + li = []; + for (i = 0; i < this.model.setData.length; i += 1) { + li.push([this.model.setData[i]]); + } - this.store = new Ext.data.ArrayStore({ - fields: [this.model.name], - data : li - }); + this.store = new Ext.data.ArrayStore({ + fields: [this.model.name], + data : li + }); - // display field an mode - this.displayField = this.model.name; - this.mode = 'local'; - - // construct the underlying class. DON'T MOVE - App.form.SetBox.superclass.initComponent.call(this); + // display field an mode + this.displayField = this.model.name; + this.mode = 'local'; + + // construct the underlying class. DON'T MOVE + App.form.SetBox.superclass.initComponent.call(this); - } + } }); Ext.reg('xsetbox', App.form.SetBox); \ No newline at end of file diff --git a/static/plugin_dbui/lib/appviewportcfg.js b/static/plugin_dbui/lib/appviewportcfg.js index 4465db4e..99af9b30 100644 --- a/static/plugin_dbui/lib/appviewportcfg.js +++ b/static/plugin_dbui/lib/appviewportcfg.js @@ -22,29 +22,29 @@ Ext.namespace('App.viewport.cfg'); App.viewport.cfg.withTreeAndTabPanels = { - layout: 'border', - title: 'Ext Layout Browser', - items: [ - { - region: 'west', - title: App.name, - width: 200, - collapsible: true, - autoScroll: true, - split: true, - xtype: 'treepanel', - rootVisible: false, - root: new Ext.tree.TreeNode({ - id: App.name, - text: App.name - }), - ref: 'treePanel' - }, { - region: 'center', - xtype: 'tabpanel', - ref: 'tabPanel', - autoScroll: true, - defaults: {layout: 'fit'} - } - ] + layout: 'border', + title: 'Ext Layout Browser', + items: [ + { + region: 'west', + title: App.name, + width: 200, + collapsible: true, + autoScroll: true, + split: true, + xtype: 'treepanel', + rootVisible: false, + root: new Ext.tree.TreeNode({ + id: App.name, + text: App.name + }), + ref: 'treePanel' + }, { + region: 'center', + xtype: 'tabpanel', + ref: 'tabPanel', + autoScroll: true, + defaults: {layout: 'fit'} + } + ] }; diff --git a/static/plugin_dbui/lib/appviewportintreebase.js b/static/plugin_dbui/lib/appviewportintreebase.js index dfd73750..3e6eedbd 100644 --- a/static/plugin_dbui/lib/appviewportintreebase.js +++ b/static/plugin_dbui/lib/appviewportintreebase.js @@ -35,165 +35,165 @@ Ext.namespace('App.viewport'); App.viewport.InTreePanelBase = Ext.extend(Object, { - /** - * @cfg {String} topNodeName name of the top node associate to this plugin. - * - */ - topNodeName: null, - - /** - * @cfg {Array} nodesId names of the nodes use for navigation - * - */ - nodesId: null, - - /** - * @cfg {Array} nodesText names of the nodes display in the interface - * If not specified use the nodeId value - */ - nodesText: null, - - /** - * @refactorTools {Object} refactorTools tool to refactor the configuration - * associate to each node. T - * - * he tool should have a method refactor. It take a configuration object as - * input an return a modified one. - */ - refactorTools: {}, - - /** - * @cfg {String} tabTitlePrefix add a prefix to the title of the tab. - * It is defined by the name of the node. - */ - tabTitlePrefix: "", - - /** - * Private parameters referring to the viewport - */ - viewport: null, - - /** - * Constructor - * @param {Object} config - */ - constructor: function (config) { - Ext.apply(this, config); - App.viewport.InTreePanelBase.superclass.constructor.apply(this); - }, - - /** - * Plugin initialization function - * @param {Ext.Viewport} viewport - */ - init: function (viewport) { - - var i, child, node, root; - - this.viewport = viewport; - - // add the top node in the tree - node = new Ext.tree.TreeNode({ - id: '/' + App.name + "/" + this.topNodeName, - text: this.topNodeName - }); - - root = viewport.treePanel.getRootNode(); - root.appendChild(node); - - // nodesText if not specified - if (!this.nodesText) { - this.nodesText = this.nodesId; - } - - //add the children and the associated handler - for (i = 0; i < this.nodesId.length; i += 1) { - - child = new Ext.tree.TreeNode({ - id: "/" + App.name + "/" + this.topNodeName + "/" + this.nodesId[i], - text: this.nodesText[i], - leaf: true - }); - - node.appendChild(child); - child.on('click', this.onCreateTab, this); - } - - viewport.tabPanel.on('beforeadd', this.addWdg, this); - }, + /** + * @cfg {String} topNodeName name of the top node associate to this plugin. + * + */ + topNodeName: null, + + /** + * @cfg {Array} nodesId names of the nodes use for navigation + * + */ + nodesId: null, + + /** + * @cfg {Array} nodesText names of the nodes display in the interface + * If not specified use the nodeId value + */ + nodesText: null, + + /** + * @refactorTools {Object} refactorTools tool to refactor the configuration + * associate to each node. T + * + * he tool should have a method refactor. It take a configuration object as + * input an return a modified one. + */ + refactorTools: {}, + + /** + * @cfg {String} tabTitlePrefix add a prefix to the title of the tab. + * It is defined by the name of the node. + */ + tabTitlePrefix: "", + + /** + * Private parameters referring to the viewport + */ + viewport: null, + + /** + * Constructor + * @param {Object} config + */ + constructor: function (config) { + Ext.apply(this, config); + App.viewport.InTreePanelBase.superclass.constructor.apply(this); + }, + + /** + * Plugin initialization function + * @param {Ext.Viewport} viewport + */ + init: function (viewport) { + + var i, child, node, root; + + this.viewport = viewport; + + // add the top node in the tree + node = new Ext.tree.TreeNode({ + id: '/' + App.name + "/" + this.topNodeName, + text: this.topNodeName + }); + + root = viewport.treePanel.getRootNode(); + root.appendChild(node); + + // nodesText if not specified + if (!this.nodesText) { + this.nodesText = this.nodesId; + } + + //add the children and the associated handler + for (i = 0; i < this.nodesId.length; i += 1) { + + child = new Ext.tree.TreeNode({ + id: "/" + App.name + "/" + this.topNodeName + "/" + this.nodesId[i], + text: this.nodesText[i], + leaf: true + }); + + node.appendChild(child); + child.on('click', this.onCreateTab, this); + } + + viewport.tabPanel.on('beforeadd', this.addWdg, this); + }, - /** - * Abstract method with should be implemented in all subclass - * Add a widget to the newly create tab/panel - * - * 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(); - * - * @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) {}, - - /** - * Helper method to return the node name from the tab id - * NOTE: Node and tab share the same identifier rule - * /App.name/TopNodeName/node. - * - * @param {String} id - */ - getNodeNameFromId: function (id) { - var li = id.split("/").reverse(); - return li[0]; - }, - - /** - * Helper method to return the top node name from the tab id - * NOTE: Node and tab share the same identifier rule - * /App.name/TopNodeName/node. - * - * @param {String} id - */ - getTopNodeNameFromId: function (id) { - var li = id.split("/").reverse(); - return li[1]; - }, - - /** - * Handler to create the tab when a node is click. - * the tab contains an empty panel - * - * @param {Object} node Ext.treeTreeNode - */ - onCreateTab: function (node) { + /** + * Abstract method with should be implemented in all subclass + * Add a widget to the newly create tab/panel + * + * 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(); + * + * @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) {}, + + /** + * Helper method to return the node name from the tab id + * NOTE: Node and tab share the same identifier rule + * /App.name/TopNodeName/node. + * + * @param {String} id + */ + getNodeNameFromId: function (id) { + var li = id.split("/").reverse(); + return li[0]; + }, + + /** + * Helper method to return the top node name from the tab id + * NOTE: Node and tab share the same identifier rule + * /App.name/TopNodeName/node. + * + * @param {String} id + */ + getTopNodeNameFromId: function (id) { + var li = id.split("/").reverse(); + return li[1]; + }, + + /** + * Handler to create the tab when a node is click. + * the tab contains an empty panel + * + * @param {Object} node Ext.treeTreeNode + */ + onCreateTab: function (node) { - var pan, tab, tabId, table; - - // is the tab already exists - tabId = node.id; - if (this.viewport.tabPanel.getItem(tabId)) { - this.viewport.tabPanel.setActiveTab(tabId); - return; - } - - // retrieve the name of the table from the tabId - table = this.getNodeNameFromId(tabId); + var pan, tab, tabId, table; + + // is the tab already exists + tabId = node.id; + if (this.viewport.tabPanel.getItem(tabId)) { + this.viewport.tabPanel.setActiveTab(tabId); + return; + } + + // retrieve the name of the table from the tabId + table = this.getNodeNameFromId(tabId); - // create a panel - pan = new Ext.Panel({ - id: tabId, - closable: true, - title: this.tabTitlePrefix + " " + table - }); - - tab = this.viewport.tabPanel.add(pan); - this.viewport.tabPanel.setActiveTab(tab.id); + // create a panel + pan = new Ext.Panel({ + id: tabId, + closable: true, + title: this.tabTitlePrefix + " " + table + }); + + 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 29c545c3..3db9bc13 100644 --- a/static/plugin_dbui/lib/appviewportintreeform.js +++ b/static/plugin_dbui/lib/appviewportintreeform.js @@ -29,36 +29,36 @@ Ext.namespace('App.viewport'); App.viewport.InTreePanelForm = Ext.extend(App.viewport.InTreePanelBase, { - /** - * private function to instantiate the grid and to add it to the tab - * - * @param {Object} container - * @param {Object} component - * @param {Object} index - */ - addWdg: function (container, component, index) { + /** + * private function to instantiate the grid and to add it to the tab + * + * @param {Object} container + * @param {Object} component + * @param {Object} index + */ + addWdg: function (container, component, index) { - var cfg, table, wdg; - - // protection -- add widget when we are concern ! - if (this.getTopNodeNameFromId(component.id) !== this.topNodeName) { - return; - } - - // get the name of the table from the tab id - table = this.getNodeNameFromId(component.id); - - // Ask the server the widget configuration and create it - cfgSvc.getFormModel(table, function (provider, response) { - - cfg = response.result; - wdg = Ext.ComponentMgr.create(cfg); - - component.add(wdg); - component.doLayout(); - - }, this); - } + var cfg, table, wdg; + + // protection -- add widget when we are concern ! + if (this.getTopNodeNameFromId(component.id) !== this.topNodeName) { + return; + } + + // get the name of the table from the tab id + table = this.getNodeNameFromId(component.id); + + // Ask the server the widget configuration and create it + cfgSvc.getFormModel(table, function (provider, response) { + + 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 2c545bbd..1d3c228b 100644 --- a/static/plugin_dbui/lib/appviewportintreegrid.js +++ b/static/plugin_dbui/lib/appviewportintreegrid.js @@ -29,68 +29,68 @@ Ext.namespace('App.viewport'); App.viewport.InTreePanelGrid = Ext.extend(App.viewport.InTreePanelBase, { - /** - * private function to instantiate the grid and to add it to the tab - * - * @param {Object} container - * @param {Object} component - * @param {Object} index - */ - addWdg: function (container, component, index) { + /** + * private function to instantiate the grid and to add it to the tab + * + * @param {Object} container + * @param {Object} component + * @param {Object} index + */ + addWdg: function (container, component, index) { - var cfg, grid, gridfilter, table, wdg; - - function createGrid(provider, response) { - cfg = response.result; - wdg = Ext.ComponentMgr.create(cfg); - - if ('filterModel' in cfg.model) { - // instantiate the grid and the filter - grid = wdg; - gridfilter = Ext.ComponentMgr.create(cfg.model.filterModel); - gridfilter.bind(grid); - - // embedded the grid and the filter in a panel - wdg = new Ext.Panel({ - layout: 'border', - border: false, - items: [{ - region: 'center', - layout: 'fit', - items: [grid] - }, { - region: 'east', - layout: 'form', - collapsible: true, - collapsed: true, - defaults: {anchor: '100%'}, - frame: true, - items: [gridfilter], - width: 300, - split: true, - buttons: [{text: 'reset', ref: '../../resetButton'}] - }] - }); + var cfg, grid, gridfilter, table, wdg; + + function createGrid(provider, response) { + cfg = response.result; + wdg = Ext.ComponentMgr.create(cfg); + + if ('filterModel' in cfg.model) { + // instantiate the grid and the filter + grid = wdg; + gridfilter = Ext.ComponentMgr.create(cfg.model.filterModel); + gridfilter.bind(grid); + + // embedded the grid and the filter in a panel + wdg = new Ext.Panel({ + layout: 'border', + border: false, + items: [{ + region: 'center', + layout: 'fit', + items: [grid] + }, { + region: 'east', + layout: 'form', + collapsible: true, + collapsed: true, + defaults: {anchor: '100%'}, + frame: true, + items: [gridfilter], + width: 300, + split: true, + buttons: [{text: 'reset', ref: '../../resetButton'}] + }] + }); - // connect the reset button - wdg.resetButton.on('click', gridfilter.onReset, gridfilter); - } - - component.add(wdg); - component.doLayout(); - } - - // protection -- add widget when we are concern ! - if (this.getTopNodeNameFromId(component.id) !== this.topNodeName) { - return; - } - - // get the name of the table from the tab id - table = this.getNodeNameFromId(component.id); - - // Ask the server the widget configuration and create it - cfgSvc.getGridModel(table, createGrid, this); - } + // connect the reset button + wdg.resetButton.on('click', gridfilter.onReset, gridfilter); + } + + component.add(wdg); + component.doLayout(); + } + + // protection -- add widget when we are concern ! + if (this.getTopNodeNameFromId(component.id) !== this.topNodeName) { + return; + } + + // get the name of the table from the tab id + table = this.getNodeNameFromId(component.id); + + // Ask the server the widget configuration and create it + cfgSvc.getGridModel(table, createGrid, this); + } }); Ext.preg('pInTreeGrid', App.viewport.InTreePanelGrid); \ No newline at end of file -- GitLab