changeset 246:c5d7fae5997a

Change logic how to show and hide the search filters. Now we iterate over the list of defined filters for the selected query and show all matching filters. If no filter is configured at all the whole filter widget is hidden.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Tue, 23 Jul 2013 14:18:11 +0200
parents 9a2c04b19874
children fa108c53da5a
files app/controller/Sql.js app/view/search/Query1.js app/view/search/Query2.js
diffstat 3 files changed, 28 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/app/controller/Sql.js	Tue Jul 23 14:16:41 2013 +0200
+++ b/app/controller/Sql.js	Tue Jul 23 14:18:11 2013 +0200
@@ -1,4 +1,5 @@
 var queries = new Array('query1', 'query2');
+
 Ext.define('Lada.controller.Sql', {
     extend: 'Ext.app.Controller',
     stores: [
@@ -31,18 +32,32 @@
     },
     selectSql: function(element, record, index) {
         var result = Ext.getCmp('result');
-        var selection = element.getValue() - 1;
-        console.log('Selected SQL ' + selection);
-        for (var i = 0; i < queries.length; ++i) {
-            var toHide = Ext.getCmp(queries[i]);
-            toHide.hide();
-        }
-        var toShow = Ext.getCmp(queries[selection]);
+        var filters = Ext.getCmp('queryfilters');
         var buttons = Ext.getCmp('SearchBtnPanel');
+        var displayFields = record[0].data.fields;
+        var filterFields = record[0].data.filters;
         this.reset();
-        var displayFields = record[0].data.fields
+
+        // Setup Columns of the probenlist
         result.setupColumns(displayFields);
-        toShow.show();
+
+        // Setup Columns of the probenlist
+        if (filterFields.length > 0) {
+            var items = filters.items.items;
+            for (var i=0; i < items.length; i++) {
+                var filtername = items[i].id;
+                items[i].hide();
+                for (var j=0; j < filterFields.length; j++) {
+                    if ('filter-'+filterFields[j] === filtername) {
+                        items[i].show();
+                    };
+                };
+
+            };
+            filters.show();
+        } else {
+            filters.hide();
+        };
         buttons.show();
     },
     search: function(element, record, index) {
@@ -77,10 +92,10 @@
     reset: function(element, record, index) {
         var buttons = Ext.getCmp('SearchBtnPanel');
         var result = Ext.getCmp('result');
-        for (var i = 0; i < queries.length; ++i) {
-            var toHide = Ext.getCmp(queries[i]);
-            toHide.hide();
-        }
+        //for (var i = 0; i < queries.length; ++i) {
+        //    var toHide = Ext.getCmp(queries[i]);
+        //    toHide.hide();
+        //}
         //result.hide();
         //buttons.hide();
     }
--- a/app/view/search/Query1.js	Tue Jul 23 14:16:41 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-Ext.define('Lada.view.search.Query1' ,{
-    extend: 'Ext.form.FieldSet',
-    title: 'Variablenbelegung',
-    alias: 'widget.query1',
-    requires: [
-        'Lada.view.widgets.Mst',
-        'Lada.view.widgets.Uwb'
-    ],
-    initComponent: function() {
-        this.items = [
-            {
-                id: 'mst',
-                xtype: 'mst',
-                fieldLabel: 'Messstelle',
-                labelWidth: 100
-            },
-            {
-                id: 'uwb',
-                xtype: 'uwb',
-                fieldLabel: 'Umweltbereich',
-                labelWidth: 100
-            }
-        ];
-        this.callParent(arguments);
-    }
-});
--- a/app/view/search/Query2.js	Tue Jul 23 14:16:41 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-Ext.define('Lada.view.search.Query2' ,{
-    extend: 'Ext.form.FieldSet',
-    alias: 'widget.query2',
-    title: 'Variablenbelegung (Zeiten in UTC)',
-    requires: [
-        'Lada.view.widgets.Datetime'
-    ],
-    initComponent: function() {
-        this.items = [
-            {
-                id: 'pbegin',
-                xtype: 'datetime',
-                fieldLabel: 'Probenbeginn',
-                labelWidth: 100
-            }
-        ];
-        this.callParent(arguments);
-    }
-});

http://lada.wald.intevation.org