Mercurial > lada > lada-client
annotate app/controller/Sql.js @ 247:fa108c53da5a
Removed data from store. queries are now loaded from the server.
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Wed, 24 Jul 2013 14:51:44 +0200 |
parents | c5d7fae5997a |
children | d79b3bab600c |
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'); |
246
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
2 |
6
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
3 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
|
4 extend: 'Ext.app.Controller', |
8
e4fcb4ddd782
Moved stored SQL into its own file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
6
diff
changeset
|
5 stores: [ |
235
78134e20e62d
Added new model and store for Queries.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
147
diff
changeset
|
6 'Proben', // List of found Proben |
78134e20e62d
Added new model and store for Queries.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
147
diff
changeset
|
7 'Queries' |
8
e4fcb4ddd782
Moved stored SQL into its own file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
6
diff
changeset
|
8 ], |
6
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
9 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
|
10 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
|
11 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
|
12 // 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
|
13 // 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
|
14 '#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
|
15 // 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
|
16 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
|
17 // 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
|
18 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
|
19 }, |
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 '#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
|
21 // 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
|
22 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
|
23 }, |
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 '#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
|
25 // 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
|
26 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
|
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 }, |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
30 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
|
31 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
|
32 }, |
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
|
33 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
|
34 var result = Ext.getCmp('result'); |
246
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
35 var filters = Ext.getCmp('queryfilters'); |
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 var buttons = Ext.getCmp('SearchBtnPanel'); |
246
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
37 var displayFields = record[0].data.fields; |
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
38 var filterFields = record[0].data.filters; |
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
|
39 this.reset(); |
246
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
40 |
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
41 // Setup Columns of the probenlist |
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
|
42 result.setupColumns(displayFields); |
246
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
43 |
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
44 // Setup Columns of the probenlist |
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
45 if (filterFields.length > 0) { |
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
46 var items = filters.items.items; |
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
47 for (var i=0; i < items.length; i++) { |
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
48 var filtername = items[i].id; |
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
49 items[i].hide(); |
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
50 for (var j=0; j < filterFields.length; j++) { |
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
51 if ('filter-'+filterFields[j] === filtername) { |
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
52 items[i].show(); |
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
53 }; |
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
54 }; |
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
55 |
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
56 }; |
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
57 filters.show(); |
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
58 } else { |
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
59 filters.hide(); |
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
60 }; |
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
|
61 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
|
62 }, |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
63 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
|
64 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
|
65 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
|
66 |
2a67e062519b
Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
35
diff
changeset
|
67 // 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
|
68 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
|
69 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
|
70 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
|
71 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
|
72 if (mst !== null) { |
139
df6e36dd57ee
Changed params probe -> probeId, mst -> mstId, uwb -> umwId
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
120
diff
changeset
|
73 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
|
74 } |
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
|
75 if (uwb !== null) { |
139
df6e36dd57ee
Changed params probe -> probeId, mst -> mstId, uwb -> umwId
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
120
diff
changeset
|
76 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
|
77 } |
36
2a67e062519b
Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
35
diff
changeset
|
78 } else { |
2a67e062519b
Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
35
diff
changeset
|
79 // 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
|
80 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
|
81 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
|
82 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
|
83 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
|
84 } |
36
2a67e062519b
Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
35
diff
changeset
|
85 } |
2a67e062519b
Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
35
diff
changeset
|
86 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
|
87 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
|
88 }); |
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
|
89 console.log('Store loaded'); |
25
f964a50bfe57
Restructured the application. Fixed layouts etc.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
17
diff
changeset
|
90 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
|
91 }, |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
92 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
|
93 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
|
94 var result = Ext.getCmp('result'); |
246
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
95 //for (var i = 0; i < queries.length; ++i) { |
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
96 // var toHide = Ext.getCmp(queries[i]); |
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
97 // toHide.hide(); |
c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
241
diff
changeset
|
98 //} |
147
5da0b56bf9bf
Do no hide the earch buttons and the resultlist on reset.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
139
diff
changeset
|
99 //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
|
100 //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
|
101 } |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
102 }); |