Mercurial > lada > lada-client
changeset 792:d572ee3271ac
some work on a context-sensitive toolbar
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Wed, 13 May 2015 13:00:13 +0200 |
parents | 56f91254cd23 |
children | d4eb8fb99b5e |
files | app/controller/Filter.js app/controller/ProbenPlanungSwitcher.js app/view/ProbenPlanungSwitcher.js app/view/grid/FilterResult.js |
diffstat | 4 files changed, 46 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/app/controller/Filter.js Wed May 13 12:40:27 2015 +0200 +++ b/app/controller/Filter.js Wed May 13 13:00:13 2015 +0200 @@ -206,10 +206,10 @@ var modes = element.up('panel[name=main]').down('radiogroup').getChecked(); var sname = modes[0].inputValue; - if (sname === 'ProbenList') { + if (sname === 'ProbeList') { sname = 'Lada.store.ProbenList'; } - else if (sname === 'MessprogrammeList') { + else if (sname === 'MessprogrammList') { sname = 'Lada.store.MessprogrammeList'; }
--- a/app/controller/ProbenPlanungSwitcher.js Wed May 13 12:40:27 2015 +0200 +++ b/app/controller/ProbenPlanungSwitcher.js Wed May 13 13:00:13 2015 +0200 @@ -26,7 +26,7 @@ init: function() { this.control({ 'radiofield[name=ppswitch]': { - check: this.switchStores + check: this.switchModes } }); this.callParent(arguments); @@ -36,22 +36,28 @@ * Function is called when the user selects a checkbox. * according to the checkboxes inputValue, * the function alters the store which was loaded by the - * filterpanels combobox + * filterpanels combobox, + * If enabled the function also disables / enables the UI-Buttons + * in the Filterresult grid. */ - switchStores: function(field) { + switchModes: function(field) { + + var disableButtons = true; + var cbox = field.up('probenplanungswitcher').up().down('combobox'); var resultGrid = field.up('panel[name=main]').down('filterresultgrid'); filters = field.up('panel[name=main]').down('fieldset[name=filtervariables]'); filters.removeAll(); filters.hide(); var sname = 'Lada.store.ProbeQueries'; - if (field.inputValue === 'MessprogrammeList' && cbox) { + if (field.inputValue === 'MessprogrammList' && cbox) { sname = 'Lada.store.MessprogrammQueries'; } - else if (field.inputValue === 'ProbenList' && cbox) { + else if (field.inputValue === 'ProbeList' && cbox) { sname = 'Lada.store.ProbeQueries'; } + var store = Ext.StoreManager.lookup(sname); if (!store) { store = Ext.create(sname);
--- a/app/view/ProbenPlanungSwitcher.js Wed May 13 12:40:27 2015 +0200 +++ b/app/view/ProbenPlanungSwitcher.js Wed May 13 13:00:13 2015 +0200 @@ -31,9 +31,9 @@ xtype: 'radiofield', name: 'ppswitch', boxLabel: i18n.getMsg('probelist'), - inputValue: 'ProbenList', //this determines the store + inputValue: 'ProbeList', //this determines the store // which will be loaded, - checked: true, + //checked: true, handler: function(field, state){ if (state === true) { this.fireEvent('check', field); @@ -43,7 +43,7 @@ xtype: 'radiofield', name: 'ppswitch', boxLabel: i18n.getMsg('probeplanning'), - inputValue: 'MessprogrammeList', //name of a store + inputValue: 'MessprogrammList', //name of a store handler: function(field, state){ if (state === true) { this.fireEvent('check', field);
--- a/app/view/grid/FilterResult.js Wed May 13 12:40:27 2015 +0200 +++ b/app/view/grid/FilterResult.js Wed May 13 13:00:13 2015 +0200 @@ -35,21 +35,25 @@ { text: 'Probe erstellen', icon: 'resources/img/list-add.png', - action: 'addProbe' + action: 'addProbe', + disabled: false }, { text: 'Messprogramm erstellen', icon: 'resources/img/list-add.png', - action: 'addMessprogramm' + action: 'addMessprogramm', + disabled: false }, '-', { text: 'Proben Importieren', icon: 'resources/img/svn-commit.png', - action: 'import' + action: 'import', + disabled: false }, { text: 'Proben Exportieren', icon: 'resources/img/svn-update.png', - action: 'export' + action: 'export', + disabled: true } ] }]; @@ -73,13 +77,29 @@ displayInfo: true }]); - //Reset the Text int the Toolbar. + //Configure the Toolbar. + this.setMode(store); + }, + + /** + * Enables or disables Toolbar-Buttons according to the selected mode + */ + setMode: function(store) { var t = Ext.getCmp('tbtitle'); - if (store.model.modelName == 'Lada.model.MessprogrammList') { + var i18n = Lada.getApplication().bundle; + if (store.model.modelName == 'Lada.model.ProbeList'){ + t.setText(i18n.getMsg('probelist')); + this.down('button[action=addMessprogramm]').disable(); + this.down('button[action=addProbe]').enable(); + this.down('button[action=import]').enable(); + this.down('button[action=export]').enable(); + } + else if (store.model.modelName == 'Lada.model.MessprogrammList') { t.setText(i18n.getMsg('probeplanning')); - } - else if (store.model.modelName == 'Lada.model.ProbeList') { - t.setText(i18n.getMsg('probelist')); + this.down('button[action=addMessprogramm]').enable(); + this.down('button[action=addProbe]').disable(); + this.down('button[action=import]').disable(); + this.down('button[action=export]').disable(); } else { t.setText(''); @@ -88,6 +108,7 @@ ' Hence the title could not be set.'); } }, + /** * Setup columns of the Grid dynamically based on a list of given cols. * The function is called from the {@link Lada.controller.Sql#selectSql