[Lada-commits] [PATCH 2 of 3] dynamically exchange the store of the resultfiltergrid

Wald Commits scm-commit at wald.intevation.org
Tue Apr 28 16:55:01 CEST 2015


# HG changeset patch
# User Dustin Demuth <dustin at intevation.de>
# Date 1430229839 -7200
# Node ID 704bb359c0fe30db36bdbc609a3e073524c5ba91
# Parent  561ade69980ee5ffb4265e26408b2aedb38dd089
dynamically exchange the store of the resultfiltergrid

diff -r 561ade69980e -r 704bb359c0fe app/controller/Filter.js
--- a/app/controller/Filter.js	Tue Apr 28 11:53:39 2015 +0200
+++ b/app/controller/Filter.js	Tue Apr 28 16:03:59 2015 +0200
@@ -188,7 +188,6 @@
      */
     search: function(element) {
         var resultGrid = element.up('panel[name=main]').down('filterresultgrid');
-        resultGrid.setupColumns(this.displayFields);
         var filters = element.up('panel[name=main]').down('fieldset[name=filtervariables]');
         var search = element.up('fieldset').down('combobox[name=filter]');
 
@@ -203,9 +202,29 @@
             }
             searchParams[filter.getName()] = value;
         }
-        resultGrid.getStore().proxy.extraParams = searchParams;
-        resultGrid.getStore().load();
-        resultGrid.show();
+        // Retrieve the mode
+        var modes = element.up('panel[name=main]').down('probenplanungswitcher').getChecked();
+        var sname = modes[0].inputValue;
+
+        if (sname === 'ProbenList') {
+            sname = 'Lada.store.ProbenList';
+        }
+        else if (sname === 'MessprogrammeList') {
+            sname = 'Lada.store.MessprogrammeList';
+        }
+
+        // Find the store or create a new one.
+        var store = Ext.StoreManager.lookup(sname);
+        if (!store) {
+            store = Ext.create(sname);
+        }
+        if (store) {
+            resultGrid.setStore(store);
+            resultGrid.setupColumns(this.displayFields);
+            resultGrid.getStore().proxy.extraParams = searchParams;
+            resultGrid.getStore().load();
+            resultGrid.show();
+        }
     },
     /**
      * This function resets the filters
diff -r 561ade69980e -r 704bb359c0fe app/controller/FilterResult.js
--- a/app/controller/FilterResult.js	Tue Apr 28 11:53:39 2015 +0200
+++ b/app/controller/FilterResult.js	Tue Apr 28 16:03:59 2015 +0200
@@ -43,6 +43,7 @@
      * The function opens a {@link Lada.view.window.ProbeEdit}
      */
     editItem: function(grid, record) {
+        console.log(record);
         var win = Ext.create('Lada.view.window.ProbeEdit', {
             record: record
         });
diff -r 561ade69980e -r 704bb359c0fe app/controller/ProbenPlanungSwitcher.js
--- a/app/controller/ProbenPlanungSwitcher.js	Tue Apr 28 11:53:39 2015 +0200
+++ b/app/controller/ProbenPlanungSwitcher.js	Tue Apr 28 16:03:59 2015 +0200
@@ -43,10 +43,10 @@
         var resultGrid = field.up('panel[name=main]').down('filterresultgrid');
 
         var sname = 'Lada.store.ProbeQueries';
-        if (field.inputValue === 'probenplanung' && cbox) {
+        if (field.inputValue === 'MessprogrammeList' && cbox) {
             sname = 'Lada.store.MessprogrammQueries';
         }
-        else if (field.inputValue === 'probenliste' && cbox) {
+        else if (field.inputValue === 'ProbenList' && cbox) {
             sname = 'Lada.store.ProbeQueries';
         }
 
diff -r 561ade69980e -r 704bb359c0fe app/model/MessprogrammList.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/model/MessprogrammList.js	Tue Apr 28 16:03:59 2015 +0200
@@ -0,0 +1,31 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+
+/**
+ * A MessprogrammList.
+ * This class represents the result list of 'Messprogramme' in the search query
+ * */
+Ext.define('Lada.model.MessprogrammList', {
+    extend: 'Ext.data.Model',
+
+    fields: [{
+        name: 'readonly'
+    }],
+
+    idProperty: 'id',
+
+    proxy: {
+        type: 'rest',
+        url: 'lada-server/messprogramm',
+        reader: {
+            type: 'json',
+            root: 'data',
+            totalProperty: 'totalCount'
+        }
+    }
+});
diff -r 561ade69980e -r 704bb359c0fe app/model/Query.js
--- a/app/model/Query.js	Tue Apr 28 11:53:39 2015 +0200
+++ b/app/model/Query.js	Tue Apr 28 16:03:59 2015 +0200
@@ -24,14 +24,5 @@
         name: 'results'
     }, {
         name: 'filters'
-    }],
-
-    proxy: {
-        type: 'rest',
-        url: 'lada-server/query/probe',
-        reader: {
-            type: 'json',
-            root: 'data'
-        }
-    }
-});
+    }]
+ });
diff -r 561ade69980e -r 704bb359c0fe app/store/MessprogrammQueries.js
--- a/app/store/MessprogrammQueries.js	Tue Apr 28 11:53:39 2015 +0200
+++ b/app/store/MessprogrammQueries.js	Tue Apr 28 16:03:59 2015 +0200
@@ -12,6 +12,7 @@
 Ext.define('Lada.store.MessprogrammQueries', {
     extend: 'Ext.data.Store',
     model: 'Lada.model.Query',
+    autolad: true,
     proxy: {
         type: 'rest',
         url: 'lada-server/query/messprogramm',
@@ -19,6 +20,5 @@
             type: 'json',
             root: 'data'
         }
-    },
-    autoLoad: true
+    }
 });
diff -r 561ade69980e -r 704bb359c0fe app/store/MessprogrammeList.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/store/MessprogrammeList.js	Tue Apr 28 16:03:59 2015 +0200
@@ -0,0 +1,17 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+
+/**
+ * Store for Messprogramme, it is used in the {@link Lada.view.grid.FilterResult}
+ */
+Ext.define('Lada.store.MessprogrammeList', {
+    extend: 'Ext.data.Store',
+    model: 'Lada.model.MessprogrammList',
+    pageSize: 50,
+    remoteSort: true
+});
diff -r 561ade69980e -r 704bb359c0fe app/store/ProbeQueries.js
--- a/app/store/ProbeQueries.js	Tue Apr 28 11:53:39 2015 +0200
+++ b/app/store/ProbeQueries.js	Tue Apr 28 16:03:59 2015 +0200
@@ -12,5 +12,13 @@
 Ext.define('Lada.store.ProbeQueries', {
     extend: 'Ext.data.Store',
     model: 'Lada.model.Query',
-    autoLoad: true
+    autoLoad: true,
+    proxy: {
+        type: 'rest',
+        url: 'lada-server/query/probe',
+        reader: {
+            type: 'json',
+            root: 'data'
+        }
+    }
 });
diff -r 561ade69980e -r 704bb359c0fe app/store/ProbenList.js
--- a/app/store/ProbenList.js	Tue Apr 28 11:53:39 2015 +0200
+++ b/app/store/ProbenList.js	Tue Apr 28 16:03:59 2015 +0200
@@ -3,11 +3,11 @@
  *
  * This file is Free Software under the GNU GPL (v>=3)
  * and comes with ABSOLUTELY NO WARRANTY! Check out
- * the documentation coming with IMIS-Labordaten-Application for details. 
+ * the documentation coming with IMIS-Labordaten-Application for details.
  */
 
 /**
- * Store for Proben
+ * Store for Proben, it is used in the {@link Lada.view.grid.FilterResult}
  */
 Ext.define('Lada.store.ProbenList', {
     extend: 'Ext.data.Store',
diff -r 561ade69980e -r 704bb359c0fe app/view/ProbenPlanungSwitcher.js
--- a/app/view/ProbenPlanungSwitcher.js	Tue Apr 28 11:53:39 2015 +0200
+++ b/app/view/ProbenPlanungSwitcher.js	Tue Apr 28 16:03:59 2015 +0200
@@ -10,7 +10,7 @@
  * This is a Widget for a ProbenPlanungSwitcher
  */
 Ext.define('Lada.view.ProbenPlanungSwitcher', {
-    extend: 'Ext.form.RadioGroup',
+    extend: 'Ext.form.FieldSet',
     alias: 'widget.probenplanungswitcher',
 
     mixins: {
@@ -21,43 +21,36 @@
      * When the Checkbox is checked, it fires a 'check' Event
      */
     initComponent: function() {
-       var i18n = Lada.getApplication().bundle;
-       this.items= [{
-            xtype: 'panel',
-            border: false,
+        var i18n = Lada.getApplication().bundle;
+        this.title = i18n.getMsg('modus');
+        this.items= [{
+            xtype: 'radiogroup',
+            columns: 1,
+            width: '100%',
             items: [{
-                xtype: 'radiogroup',
-                fieldLabel: i18n.getMsg('modus'),
-                //labelWidth: '30 px',
-                columns: 'auto',
-                vertical: false,
-                width: '100%',
-                items: [{
-                    xtype: 'radiofield',
-                    name: 'ppswitch',
-                    boxLabel: i18n.getMsg('probelist'),
-                    boxLabelAlign: 'before',
-                    inputValue: 'probenliste',
-                    checked: true,
-                    handler: function(field, state){
-                        if (state === true) {
-                            this.fireEvent('check', field);
-                        }
+                xtype: 'radiofield',
+                name: 'ppswitch',
+                boxLabel: i18n.getMsg('probelist'),
+                inputValue: 'ProbenList', //this determines the store
+                    // which will be loaded,
+                checked: true,
+                handler: function(field, state){
+                    if (state === true) {
+                        this.fireEvent('check', field);
                     }
-                },{
-                    xtype: 'radiofield',
-                    name: 'ppswitch',
-                    boxLabel: i18n.getMsg('probeplanning'),
-                    boxLabelAlign: 'before',
-                    inputValue: 'probenplanung',
-                    handler: function(field, state){
-                        if (state === true) {
-                            this.fireEvent('check', field);
-                        }
+                }
+            },{
+                xtype: 'radiofield',
+                name: 'ppswitch',
+                boxLabel: i18n.getMsg('probeplanning'),
+                inputValue: 'MessprogrammeList', //name of a store
+                handler: function(field, state){
+                    if (state === true) {
+                        this.fireEvent('check', field);
                     }
-                 }]
+                }
             }]
-       }];
-       this.callParent(arguments);
+        }];
+        this.callParent(arguments);
     }
 });
diff -r 561ade69980e -r 704bb359c0fe app/view/grid/FilterResult.js
--- a/app/view/grid/FilterResult.js	Tue Apr 28 11:53:39 2015 +0200
+++ b/app/view/grid/FilterResult.js	Tue Apr 28 16:03:59 2015 +0200
@@ -13,7 +13,7 @@
     extend: 'Ext.grid.Panel',
     alias: 'widget.filterresultgrid',
 
-    store: 'ProbenList',
+    store: null, //'ProbenList',
 
     multiSelect: true,
 
@@ -39,17 +39,26 @@
                 icon: 'resources/img/svn-update.png',
                 action: 'export'
             }]
-        }, {
-            xtype: 'pagingtoolbar',
-            dock: 'bottom',
-            store: this.store,
-            displayInfo: true
         }];
         this.columns = [];
         this.callParent(arguments);
     },
 
     /**
+     * This sets the Store of the FilterResultGrid
+     */
+    setStore: function(store){
+        this.removeDocked(Ext.getCmp('ptbar'), true);
+        this.reconfigure(store);
+        this.addDocked([{
+            xtype: 'pagingtoolbar',
+            id: 'ptbar',
+            dock: 'bottom',
+            store: store,
+            displayInfo: true
+        }]);
+    },
+    /**
      * Setup columns of the Grid dynamically based on a list of given cols.
      * The function is called from the {@link Lada.controller.Sql#selectSql
      * select sql event}
diff -r 561ade69980e -r 704bb359c0fe resources/i18n/Lada_de-DE.properties
--- a/resources/i18n/Lada_de-DE.properties	Tue Apr 28 11:53:39 2015 +0200
+++ b/resources/i18n/Lada_de-DE.properties	Tue Apr 28 16:03:59 2015 +0200
@@ -37,8 +37,8 @@
 probeentnahmeBeginn: Probeentnahme Beginn
 
 modus: Modus
-probeplanning: Probenplanung
-probelist: Probenliste
+probeplanning: Messprogramme
+probelist: Proben
 
 ##
 # Msg:


More information about the Lada-commits mailing list