diff app/controller/Sql.js @ 31:897e3100c6da

Changed logic of the Probenauswahl. Now logic works like the BFS version.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Tue, 21 May 2013 17:53:51 +0200
parents 4d60b9ebce15
children a35119566841
line wrap: on
line diff
--- a/app/controller/Sql.js	Thu May 16 18:26:05 2013 +0200
+++ b/app/controller/Sql.js	Tue May 21 17:53:51 2013 +0200
@@ -1,3 +1,4 @@
+var queries = new Array('query1', 'query2');
 Ext.define('Lada.controller.Sql', {
     extend: 'Ext.app.Controller',
     views: [
@@ -11,11 +12,19 @@
         this.control({
             // CSS like selector to select element in the viewport. See
             // ComponentQuery documentation for more details.
-            'queryselector': {
+            '#search': {
                 // Map the "render" event to the given function.
                 render: this.onPanelRendered,
                 // Map Doubleclick on rows of the probenlist.
                 select: this.selectSql
+            },
+            '#SearchBtn': {
+                // Map click event on Button.
+                click: this.search
+            },
+            '#ResetBtn': {
+                // Map click event on Button.
+                click: this.reset
             }
         });
     },
@@ -23,47 +32,33 @@
         console.log('The panel was rendered');
     },
     selectSql: function(element, record, index) {
-        //var selection = record.get('id');
-        var selection = index;
-        var variables = Ext.getCmp('variables');
-        var result = Ext.getCmp('result');
+        var selection = element.getValue() - 1;
         console.log('Selected SQL ' + selection);
-        //// Set correct form for the current SQL-Selection
-        //console.log('Length is ' + variables.items.length);
-        //if (variables.items.length > 1) {
-        //    console.log('Length is > than 1');
-        //    variables.remove(currentVar.id);
-        //}
-        //if (selection == 1) {
-        //    currentVar = variables1;
-        //}
-        //else {
-        //    currentVar = variables2;
-        //}
-        //variables.add(currentVar);
-        //// Show the panel for the variable definiton.
-        //variables.show();
-
-        // Show the results.
+        for (var i = 0; i < queries.length; ++i) {
+            var toHide = Ext.getCmp(queries[i]);
+            toHide.hide();
+        }
+        var toShow = Ext.getCmp(queries[selection]);
+        var buttons = Ext.getCmp('SearchBtnPanel');
+        this.reset();
+        toShow.show();
+        buttons.show();
+    },
+    search: function(element, record, index) {
+        var result = Ext.getCmp('result');
         console.log('Loading store');
         result.getStore().load();
         console.log('Store loaded');
         result.show();
+    },
+    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();
+        }
+        result.hide();
+        buttons.hide();
     }
 });
-
-
-var currentVar = null;
-var variables1 = {
-    xtype: 'panel',
-    id: 'variable1',
-    border: false,
-    html: 'Variablen für Abfrage 1'
-};
-
-var variables2 = {
-    xtype: 'panel',
-    id: 'variable2',
-    border: false,
-    html: 'Variablen für Abfrage 2'
-};

http://lada.wald.intevation.org