From 3911530283d3c8d33ccc4be08528017f4c0f19e8 Mon Sep 17 00:00:00 2001 From: legac <renaud.legac@free.fr> Date: Thu, 5 Jul 2012 21:58:14 +0200 Subject: [PATCH] Redesign the bottom tool bar of the grid and the associated plugins. --- models/widgets.py | 5 +- static/plugin_dbui/CHANGELOG | 3 +- static/plugin_dbui/locale/dbui-lang-fr.js | 7 ++- static/plugin_dbui/src/appgrid.js | 5 +- static/plugin_dbui/src/appgridexport.js | 38 ++++++++++++++ static/plugin_dbui/src/appgridpaging.js | 60 ++++++++++------------- 6 files changed, 77 insertions(+), 41 deletions(-) create mode 100644 static/plugin_dbui/src/appgridexport.js diff --git a/models/widgets.py b/models/widgets.py index 4c4675c6..3a2eb0ee 100755 --- a/models/widgets.py +++ b/models/widgets.py @@ -12,7 +12,8 @@ dbui = local_import('plugin_dbui') # dbui.configure_grids(db, plugins=['pGridRowEditorConfirmDelete', 'pGridRowEditorContextMenu', - 'pGridRowEditorDblClick']) + 'pGridRowEditorDblClick', + 'pGridExport']) dbui.configure_forms(db, plugins=['pFormToolTip']) @@ -146,7 +147,7 @@ tpl = ['<b>{PublicationsTitle}</b><br>', ] gridModifier = dbui.GridModifier('publications') -gridModifier.append_plugins('pGridPaging', 'pGridMathJax') +gridModifier.append_plugins('pGridPaging', 'pGridExport', 'pGridMathJax') gridModifier.merge_columns('title', 'authors', 'id_collaborations', diff --git a/static/plugin_dbui/CHANGELOG b/static/plugin_dbui/CHANGELOG index d4764092..84e2ee0c 100644 --- a/static/plugin_dbui/CHANGELOG +++ b/static/plugin_dbui/CHANGELOG @@ -3,7 +3,8 @@ HEAD - Add a StoreModifier to handle the orderby directive - - Add a plugin pGridRowEditorDblClick. + - Add a plugin pGridRowEditorDblClick and pGridExport + - Redesign the bottom toolbar for grid 0.4.7.3 (Jun 2012) - Consolidation version diff --git a/static/plugin_dbui/locale/dbui-lang-fr.js b/static/plugin_dbui/locale/dbui-lang-fr.js index 6661d8cb..f57c4033 100644 --- a/static/plugin_dbui/locale/dbui-lang-fr.js +++ b/static/plugin_dbui/locale/dbui-lang-fr.js @@ -20,6 +20,12 @@ if (App.form.FormPanel) { }); } +if (App.grid.Export) { + Ext.apply(App.grid.Export.prototype, { + textExport: 'Exporter dans un fichier CSV' + }); +} + if (App.grid.GridWithFilter) { Ext.apply(App.grid.GridWithFilter.prototype, { textReset: 'Annuler' @@ -28,7 +34,6 @@ if (App.grid.GridWithFilter) { if (App.grid.Paging) { Ext.apply(App.grid.Paging.prototype, { - textExport: 'Exporter', textReset: 'Remise à zéro', textSlider: 'Enregistrements par page' }); diff --git a/static/plugin_dbui/src/appgrid.js b/static/plugin_dbui/src/appgrid.js index f7cf7a8b..e1885fac 100644 --- a/static/plugin_dbui/src/appgrid.js +++ b/static/plugin_dbui/src/appgrid.js @@ -46,9 +46,8 @@ App.grid.Grid = Ext.extend(Ext.grid.GridPanel, { // link the grid to the data store this.store = App.getDirectStore(this.store); - // empty Paging toolBar requires by the plugins - this.bbar = new Ext.PagingToolbar(); - this.bbar.hide(); + // empty toolBar requires by the plugins + this.bbar = new Ext.Toolbar(); // initialize the underlying class. DON'T MOVE App.grid.Grid.superclass.initComponent.call(this); diff --git a/static/plugin_dbui/src/appgridexport.js b/static/plugin_dbui/src/appgridexport.js new file mode 100644 index 00000000..2785dc72 --- /dev/null +++ b/static/plugin_dbui/src/appgridexport.js @@ -0,0 +1,38 @@ +/** + * The grid export plugin for toolbar + * The ptype of this component is pGridExport. + * + * @version + * + */ +Ext.namespace('App.grid'); + +App.grid.Export = Ext.extend(Object, { + + /** + * Private parameter identifying the type of plugin + */ + ptype: 'pGridExport', + + /** + * Private attribute for internationalization + */ + textExport: 'Export to CSV file', + + /** + * Plugin initialization + */ + init: function(grid){ + var bbar = grid.getBottomToolbar() + bbar.add( + '->', { + xtype: 'xbuttondownload', + iconCls: 'xaction-export', + tooltip: this.textExport, + url: App.csvUrl + '?tableName=' + App.getTableName(grid.store) + } + ); + } +}); + +Ext.preg('pGridExport', App.grid.Export); diff --git a/static/plugin_dbui/src/appgridpaging.js b/static/plugin_dbui/src/appgridpaging.js index 4fd1720e..d4286a24 100644 --- a/static/plugin_dbui/src/appgridpaging.js +++ b/static/plugin_dbui/src/appgridpaging.js @@ -21,7 +21,6 @@ App.grid.Paging = Ext.extend(Object, { /** * Private attributs for internationalization */ - textExport: 'Export', textReset: 'Reset', textSlider: 'Rows per page', @@ -32,40 +31,33 @@ App.grid.Paging = Ext.extend(Object, { var bbar; - // link the bbar and the grid store - bbar = grid.getBottomToolbar(); - bbar.bindStore(grid.store); + // create the paging bar + bbar = new Ext.PagingToolbar({store: grid.store}); - // add the slider and the export button - bbar.add('-', - this.textSlider, - { - xtype: 'slider', - plugins: new Ext.slider.Tip(), - listeners: { - changecomplete: this.onChangePageSize, - scope: bbar - }, - minValue: 1, - width: 100 - }, - '-', - {xtype: 'button', - iconCls: 'xaction-download', - listeners: {click: this.onReset, - scope: grid}, - tooltip: this.textReset}, - '-', - '->', - { - xtype: 'xbuttondownload', - iconCls: 'xaction-export', - tooltip: this.textExport, - url: App.csvUrl + '?tableName=' + App.getTableName(grid.store) - } - ); - - bbar.show(); + // replace the bottomtool bar by the pagingtool bar + grid.bottomToolbar = bbar; + + // add slider and export button + bbar.add( + '-', + this.textSlider, + { + xtype: 'slider', + plugins: new Ext.slider.Tip(), + listeners: { + changecomplete: this.onChangePageSize, + scope: bbar + }, + minValue: 1, + width: 100 + }, '-', { + xtype: 'button', + iconCls: 'xaction-download', + listeners: {click: this.onReset, + scope: grid}, + tooltip: this.textReset + }, '-' + ); // Initialize the parameters of the paging and slider widgets. // Depends on the status of the store. -- GitLab