changeset 751:704bb359c0fe

dynamically exchange the store of the resultfiltergrid
author Dustin Demuth <dustin@intevation.de>
date Tue, 28 Apr 2015 16:03:59 +0200
parents 561ade69980e
children 639e82e2089e
files app/controller/Filter.js app/controller/FilterResult.js app/controller/ProbenPlanungSwitcher.js app/model/MessprogrammList.js app/model/Query.js app/store/MessprogrammQueries.js app/store/MessprogrammeList.js app/store/ProbeQueries.js app/store/ProbenList.js app/view/ProbenPlanungSwitcher.js app/view/grid/FilterResult.js resources/i18n/Lada_de-DE.properties
diffstat 12 files changed, 134 insertions(+), 65 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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
         });
--- 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';
         }
 
--- /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'
+        }
+    }
+});
--- 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'
-        }
-    }
-});
+    }]
+ });
--- 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
+    }
 });
--- /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
+});
--- 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'
+        }
+    }
 });
--- 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',
--- 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);
     }
 });
--- 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}
--- 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:

http://lada.wald.intevation.org