[Lada-commits] [PATCH 2 of 3] some work on a context-sensitive toolbar
Wald Commits
scm-commit at wald.intevation.org
Wed May 13 16:02:28 CEST 2015
# HG changeset patch
# User Dustin Demuth <dustin at intevation.de>
# Date 1431514813 -7200
# Node ID d572ee3271acb407c3fd46abc4d442bcfcab3a70
# Parent 56f91254cd236cd9be1a5c46c9e4ec5da164a92a
some work on a context-sensitive toolbar
diff -r 56f91254cd23 -r d572ee3271ac app/controller/Filter.js
--- 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';
}
diff -r 56f91254cd23 -r d572ee3271ac app/controller/ProbenPlanungSwitcher.js
--- 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);
diff -r 56f91254cd23 -r d572ee3271ac app/view/ProbenPlanungSwitcher.js
--- 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);
diff -r 56f91254cd23 -r d572ee3271ac app/view/grid/FilterResult.js
--- 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
More information about the Lada-commits
mailing list