annotate app/controller/Sql.js @ 241:4ca858026191

If the user selects a search query add call setupColumns method to dynamically add columns to the table as defined in the searach query.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Tue, 23 Jul 2013 11:31:47 +0200
parents 78134e20e62d
children c5d7fae5997a
rev   line source
31
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
1 var queries = new Array('query1', 'query2');
6
8e79bda4d55b Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
2 Ext.define('Lada.controller.Sql', {
8e79bda4d55b Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
3 extend: 'Ext.app.Controller',
8
e4fcb4ddd782 Moved stored SQL into its own file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 6
diff changeset
4 stores: [
235
78134e20e62d Added new model and store for Queries.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 147
diff changeset
5 'Proben', // List of found Proben
78134e20e62d Added new model and store for Queries.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 147
diff changeset
6 'Queries'
8
e4fcb4ddd782 Moved stored SQL into its own file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 6
diff changeset
7 ],
6
8e79bda4d55b Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
8 init: function() {
8e79bda4d55b Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
9 console.log('Initialising the Sql controller');
8e79bda4d55b Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
10 this.control({
8e79bda4d55b Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
11 // CSS like selector to select element in the viewport. See
8e79bda4d55b Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
12 // ComponentQuery documentation for more details.
31
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
13 '#search': {
6
8e79bda4d55b Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
14 // Map the "render" event to the given function.
8e79bda4d55b Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
15 render: this.onPanelRendered,
8e79bda4d55b Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
16 // Map Doubleclick on rows of the probenlist.
28
4d60b9ebce15 Renamed sql modul into search. Further display The query selection as Combobox
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 25
diff changeset
17 select: this.selectSql
31
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
18 },
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
19 '#SearchBtn': {
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
20 // Map click event on Button.
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
21 click: this.search
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
22 },
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
23 '#ResetBtn': {
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
24 // Map click event on Button.
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
25 click: this.reset
6
8e79bda4d55b Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
26 }
8e79bda4d55b Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
27 });
8e79bda4d55b Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
28 },
8e79bda4d55b Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
29 onPanelRendered: function() {
8e79bda4d55b Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
30 console.log('The panel was rendered');
8e79bda4d55b Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
31 },
28
4d60b9ebce15 Renamed sql modul into search. Further display The query selection as Combobox
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 25
diff changeset
32 selectSql: function(element, record, index) {
241
4ca858026191 If the user selects a search query add call setupColumns method to dynamically
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 235
diff changeset
33 var result = Ext.getCmp('result');
31
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
34 var selection = element.getValue() - 1;
25
f964a50bfe57 Restructured the application. Fixed layouts etc.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 17
diff changeset
35 console.log('Selected SQL ' + selection);
31
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
36 for (var i = 0; i < queries.length; ++i) {
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
37 var toHide = Ext.getCmp(queries[i]);
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
38 toHide.hide();
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
39 }
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
40 var toShow = Ext.getCmp(queries[selection]);
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
41 var buttons = Ext.getCmp('SearchBtnPanel');
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
42 this.reset();
241
4ca858026191 If the user selects a search query add call setupColumns method to dynamically
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 235
diff changeset
43 var displayFields = record[0].data.fields
4ca858026191 If the user selects a search query add call setupColumns method to dynamically
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 235
diff changeset
44 result.setupColumns(displayFields);
31
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
45 toShow.show();
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
46 buttons.show();
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
47 },
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
48 search: function(element, record, index) {
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
49 var result = Ext.getCmp('result');
28
4d60b9ebce15 Renamed sql modul into search. Further display The query selection as Combobox
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 25
diff changeset
50 console.log('Loading store');
36
2a67e062519b Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 35
diff changeset
51
2a67e062519b Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 35
diff changeset
52 // Get search parameters:
2a67e062519b Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 35
diff changeset
53 var searchParams = {};
2a67e062519b Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 35
diff changeset
54 if (Ext.getCmp('search').getValue() == 1) {
96
ecb0c0cf386b Only add search params if the user actually set them in the form.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 36
diff changeset
55 var mst = Ext.getCmp('mst').getValue();
ecb0c0cf386b Only add search params if the user actually set them in the form.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 36
diff changeset
56 var uwb = Ext.getCmp('uwb').getValue();
ecb0c0cf386b Only add search params if the user actually set them in the form.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 36
diff changeset
57 if (mst !== null) {
139
df6e36dd57ee Changed params probe -> probeId, mst -> mstId, uwb -> umwId
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 120
diff changeset
58 searchParams['mstId'] = mst;
96
ecb0c0cf386b Only add search params if the user actually set them in the form.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 36
diff changeset
59 }
ecb0c0cf386b Only add search params if the user actually set them in the form.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 36
diff changeset
60 if (uwb !== null) {
139
df6e36dd57ee Changed params probe -> probeId, mst -> mstId, uwb -> umwId
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 120
diff changeset
61 searchParams['umwId'] = uwb;
96
ecb0c0cf386b Only add search params if the user actually set them in the form.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 36
diff changeset
62 }
36
2a67e062519b Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 35
diff changeset
63 } else {
2a67e062519b Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 35
diff changeset
64 // Get date object an convert it into a timestamp (ms since epoch)
97
9a549ca6e664 Only getTimte from datefield if the value is not null.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 96
diff changeset
65 var datefield = Ext.getCmp('pbegin').getValue();
9a549ca6e664 Only getTimte from datefield if the value is not null.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 96
diff changeset
66 if (datefield !== null) {
9a549ca6e664 Only getTimte from datefield if the value is not null.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 96
diff changeset
67 var ts = Ext.getCmp('pbegin').getValue().getTime();
96
ecb0c0cf386b Only add search params if the user actually set them in the form.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 36
diff changeset
68 searchParams['begin'] = ts;
ecb0c0cf386b Only add search params if the user actually set them in the form.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 36
diff changeset
69 }
36
2a67e062519b Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 35
diff changeset
70 }
2a67e062519b Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 35
diff changeset
71 result.getStore().load({
2a67e062519b Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 35
diff changeset
72 params: searchParams
2a67e062519b Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 35
diff changeset
73 });
28
4d60b9ebce15 Renamed sql modul into search. Further display The query selection as Combobox
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 25
diff changeset
74 console.log('Store loaded');
25
f964a50bfe57 Restructured the application. Fixed layouts etc.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 17
diff changeset
75 result.show();
31
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
76 },
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
77 reset: function(element, record, index) {
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
78 var buttons = Ext.getCmp('SearchBtnPanel');
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
79 var result = Ext.getCmp('result');
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
80 for (var i = 0; i < queries.length; ++i) {
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
81 var toHide = Ext.getCmp(queries[i]);
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
82 toHide.hide();
897e3100c6da Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 28
diff changeset
83 }
147
5da0b56bf9bf Do no hide the earch buttons and the resultlist on reset.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 139
diff changeset
84 //result.hide();
5da0b56bf9bf Do no hide the earch buttons and the resultlist on reset.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 139
diff changeset
85 //buttons.hide();
6
8e79bda4d55b Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
86 }
8e79bda4d55b Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
87 });

http://lada.wald.intevation.org