diff app/controller/ProbenPlanungSwitcher.js @ 975:fb99332bb48e stammdatengrids

Severe changes concerning the Resultgrids. - Intrduced "Stammdaten" which can be selected in the Mode Field on the left side, - Added Stores and Models for the Stammdaten - Removed the FilterResultgrid and replaced it with a model which uses inheritance. Dynamic Grid Columns can now be derived from app/view/widget/DynamicGrid.js For Proben and Messprogramme this is already done. - There might be some REGRESSION concerning the buttons in the ProbeList and MessprogrammeList grid, as those are not disabled properly. This needs to be fixed in future commits.
author Dustin Demuth <dustin@intevation.de>
date Wed, 02 Dec 2015 17:39:04 +0100
parents 96e04c258b8f
children
line wrap: on
line diff
--- a/app/controller/ProbenPlanungSwitcher.js	Mon Nov 30 14:52:59 2015 +0100
+++ b/app/controller/ProbenPlanungSwitcher.js	Wed Dec 02 17:39:04 2015 +0100
@@ -16,7 +16,8 @@
 
     requires: [
         'Lada.store.MessprogrammQueries',
-        'Lada.store.ProbeQueries'
+        'Lada.store.ProbeQueries',
+        'Lada.store.StammdatenQueries'
     ],
 
     /**
@@ -38,59 +39,55 @@
      * according to the checkboxes inputValue,
      * the function alters the store which was loaded by the
      * filterpanels combobox,
-     * If enabled the function also disables / enables the UI-Buttons
-     * in the Filterresult grid.
      */
     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';
-        var gridsname = 'Lada.store.ProbenList';
-        if (field.inputValue === 'MessprogrammList' && cbox) {
-            sname = 'Lada.store.MessprogrammQueries';
-            gridsname = 'Lada.store.MessprogrammeList';
+
+        //Initialise variables which will define the querystore
+        // and the store which has to be loaded into the grid.
+        var querystorename = '';
+
+        // In dependence of the checkboxes input value,
+        // define the store of the filter.
+        //    app/controller/Filter.js contains similar code.
+        if (field.inputValue === 'messprogramme' && cbox) {
+            querystorename = 'Lada.store.MessprogrammQueries';
         }
-        else if (field.inputValue === 'ProbeList' && cbox) {
-            sname = 'Lada.store.ProbeQueries';
-            gridsname = 'Lada.store.ProbenList';
+        else if (field.inputValue === 'proben' && cbox) {
+            querystorename = 'Lada.store.ProbeQueries';
+        }
+        else if (field.inputValue === 'stammdaten' && cbox) {
+            querystorename = 'Lada.store.StammdatenQueries';
         }
 
-
-        var store = Ext.StoreManager.lookup(sname);
+        if (querystorename) {
+            var store = Ext.StoreManager.lookup(querystorename);
 
-        if (!store) {
-            store = Ext.create(sname, {
-                //Select first Item on Load
-                listeners: {
-                    load: function(s){
-                        var records = new Array();
-                        records.push(store.getAt(0));
+            if (!store) {
+                store = Ext.create(querystorename, {
+                    //Select first Item on Load
+                    listeners: {
+                        load: function(store){
+                            var records = new Array();
+                            records.push(store.getAt(0));
 
-                        cbox.select(records[0]);
-                        cbox.fireEvent('select', cbox, records);
+                            cbox.select(records[0]);
+                            cbox.fireEvent('select', cbox, records);
+                        }
                     }
+                });
+            }
+
+            if (store) {
+                if (!store.autoLoad) {
+                    store.load();
                 }
-            });
-        }
-        if (store) {
-            store.load();
-            cbox.reset();
-            cbox.bindStore(store);
+                //cbox.reset();
+                cbox.bindStore(store);
+            }
         }
-
-        var gridstore = Ext.StoreManager.lookup(gridsname);
-        if (!gridstore) {
-            gridstore = Ext.create(gridsname);
-        }
-        if (gridstore) {
-            resultGrid.setStore(gridstore);
-            resultGrid.show();
-        }
-
     }
 });

http://lada.wald.intevation.org