changeset 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 c684f01c0b72
children 162552e878e7
files app/controller/Sql.js app/view/Viewport.js app/view/search/List.js app/view/search/Query1.js app/view/search/Query2.js app/view/search/Variables.js app/view/widgets/Datetime.js app/view/widgets/Mst.js app/view/widgets/Uwb.js
diffstat 9 files changed, 190 insertions(+), 80 deletions(-) [+]
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'
-};
--- a/app/view/Viewport.js	Thu May 16 18:26:05 2013 +0200
+++ b/app/view/Viewport.js	Tue May 21 17:53:51 2013 +0200
@@ -2,7 +2,8 @@
     extend: 'Ext.container.Viewport',
     requires: [
         'Lada.view.search.List',
-        'Lada.view.search.Variables',
+        'Lada.view.search.Query1',
+        'Lada.view.search.Query2',
         'Lada.view.proben.List'
     ],
     initComponent: function() {
@@ -12,19 +13,50 @@
             title: '<center>Probenauswahlmaske</center>',
             bodyPadding: '10 10',
             items: [
+                // Auswahl einer Abfrage.
                 {
                     xtype: 'queryselector',
                     margin: '0 0 10 0'
                 },
                 // Variables settings for the current selected sql statement.
-                //{
-                //    id: 'variables',
-                //    xtype: 'variables'
-                //},
+                {
+                    id: 'query1',
+                    xtype: 'query1',
+                    hidden: true
+                },
+                {
+                    id: 'query2',
+                    xtype: 'query2',
+                    hidden: true
+
+                },
+                {
+                    id: 'SearchBtnPanel',
+                    xtype: 'panel',
+                    border: false,
+                    margin: '0 0 10 0',
+                    items: [
+                        {
+                            id: 'SearchBtn',
+                            text: 'Suchen',
+                            xtype: 'button',
+                            margin: '0 10 0 0'
+                        },
+                        {
+                            id: 'ResetBtn',
+                            text: 'Zurücksetzen',
+                            xtype: 'button'
+                        }
+                    ],
+                    hidden: true
+
+                },
+                // Buttons to trigger the search.
                 // Resultlist for the query.
                 {
                     id: 'result',
-                    xtype: 'probenlist'
+                    xtype: 'probenlist',
+                    hidden: true
                 }
             ]
         };
--- a/app/view/search/List.js	Thu May 16 18:26:05 2013 +0200
+++ b/app/view/search/List.js	Tue May 21 17:53:51 2013 +0200
@@ -1,31 +1,19 @@
 Ext.define('Lada.view.search.List' ,{
-        extend: 'Ext.form.ComboBox',
-        alias: 'widget.queryselector',
-        store: 'Sql',
-        displayField:'name',
-        valueField: 'id' ,
-        emptyText:'Wählen Sie eine Abfrage',
-        //typeAhead: true,
-        //mode: 'local',
-        //triggerAction: 'all',
-        //selectOnFocus:true,
+    extend: 'Ext.form.FieldSet',
+    title: 'SQL-Auswahl',
+    alias: 'widget.queryselector',
 
     initComponent: function() {
+        this.items = [
+            {
+                id: 'search',
+                xtype: 'combobox',
+                store: 'Sql',
+                displayField:'name',
+                valueField:'id',
+                emptyText:'Wählen Sie eine Abfrage'
+            }
+        ];
         this.callParent(arguments);
     }
 });
-//Ext.define('Lada.view.search.List' ,{
-//    extend: 'Ext.grid.Panel',
-//    alias: 'widget.queryselector',
-//    store: 'Sql',
-//
-//    initComponent: function() {
-//        this.columns = [
-//            {header: 'ID',  dataIndex: 'id',  flex: 1},
-//            {header: 'Kurzname', dataIndex: 'name', flex: 1},
-//            {header: 'SQL', dataIndex: 'desc', flex: 1}
-//        ];
-//
-//        this.callParent(arguments);
-//    }
-//});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/search/Query1.js	Tue May 21 17:53:51 2013 +0200
@@ -0,0 +1,26 @@
+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);
+    }
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/search/Query2.js	Tue May 21 17:53:51 2013 +0200
@@ -0,0 +1,19 @@
+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);
+    }
+});
--- a/app/view/search/Variables.js	Thu May 16 18:26:05 2013 +0200
+++ b/app/view/search/Variables.js	Tue May 21 17:53:51 2013 +0200
@@ -1,23 +1,40 @@
 Ext.define('Lada.view.search.Variables' ,{
-    extend: 'Ext.panel.Panel',
-    alias: 'widget.variables',
-    border: false,
-
+        extend: 'Ext.panel.Panel',
+        alias: 'widget.variables1',
+        border: false,
     initComponent: function() {
         this.items = [
             {
                 id: 'sqlVar1',
-                xtype: 'displayfield',
+                xtype: 'queryselector',
                 fieldLabel: 'Variables for SQL 1',
                 labelWidth: 300
-            },
-            {
-                id: 'sqlVar2',
-                xtype: 'displayfield',
-                fieldLabel: 'Variables for SQL 2',
-                labelWidth: 300
             }
         ];
         this.callParent(arguments);
     }
 });
+
+//Ext.define('Lada.view.search.Variables' ,{
+//    extend: 'Ext.panel.Panel',
+//    alias: 'widget.variables',
+//    border: false,
+//
+//    initComponent: function() {
+//        this.items = [
+//            {
+//                id: 'sqlVar1',
+//                xtype: 'displayfield',
+//                fieldLabel: 'Variables for SQL 1',
+//                labelWidth: 300
+//            },
+//            {
+//                id: 'sqlVar2',
+//                xtype: 'displayfield',
+//                fieldLabel: 'Variables for SQL 2',
+//                labelWidth: 300
+//            }
+//        ];
+//        this.callParent(arguments);
+//    }
+//});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/widgets/Datetime.js	Tue May 21 17:53:51 2013 +0200
@@ -0,0 +1,9 @@
+// Combobox for Time and Dates
+Ext.define('Lada.view.widgets.Datetime' ,{
+        extend: 'Ext.form.Date',
+        alias: 'widget.datetime',
+        emptyText:'Wählen Sie einen Zeitpunkt',
+    initComponent: function() {
+        this.callParent(arguments);
+    }
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/widgets/Mst.js	Tue May 21 17:53:51 2013 +0200
@@ -0,0 +1,12 @@
+// Combobox for Messtelle
+Ext.define('Lada.view.widgets.Mst' ,{
+        extend: 'Ext.form.ComboBox',
+        alias: 'widget.mst',
+        store: 'Sql',
+        displayField:'name',
+        valueField: 'id' ,
+        emptyText:'Wählen Sie eine Messstelle',
+    initComponent: function() {
+        this.callParent(arguments);
+    }
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/widgets/Uwb.js	Tue May 21 17:53:51 2013 +0200
@@ -0,0 +1,12 @@
+// Combobox for Umweltbereich
+Ext.define('Lada.view.widgets.Uwb' ,{
+        extend: 'Ext.form.ComboBox',
+        alias: 'widget.uwb',
+        store: 'Sql',
+        displayField:'name',
+        valueField: 'id',
+        emptyText:'Wählen Sie eine Abfrage',
+    initComponent: function() {
+        this.callParent(arguments);
+    }
+});

http://lada.wald.intevation.org