Mercurial > lada > lada-client
annotate app/controller/Sql.js @ 18:9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
which is currently just a dummy file to make to request work. But currently no
data is actually saved. The urls need to be replaced with the correct urls in
the application backend.
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Mon, 06 May 2013 16:41:39 +0200 |
parents | 3eaeeec2bb28 |
children | f964a50bfe57 |
rev | line source |
---|---|
6
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
1 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
|
2 extend: 'Ext.app.Controller', |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
3 views: [ |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
4 'sql.List' |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
5 ], |
8
e4fcb4ddd782
Moved stored SQL into its own file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
6
diff
changeset
|
6 stores: [ |
e4fcb4ddd782
Moved stored SQL into its own file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
6
diff
changeset
|
7 'Sql' |
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. |
17
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
14 'sqllist': { |
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. |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
18 itemclick: this.selectSql |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
19 } |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
20 }); |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
21 }, |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
22 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
|
23 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
|
24 }, |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
25 selectSql: function(grid, record) { |
17
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
26 var selection = record.get('id'); |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
27 var variables = Ext.getCmp('searchVariables'); |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
28 console.log('Selected SQL' + selection); |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
29 // Set correct form for the current SQL-Selection |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
30 console.log('Length is ' + variables.items.length); |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
31 if (variables.items.length > 1) { |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
32 console.log('Length is > than 1'); |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
33 variables.remove(currentVar.id); |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
34 } |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
35 if (selection == 1) { |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
36 currentVar = variables1; |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
37 } |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
38 else { |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
39 currentVar = variables2; |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
40 } |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
41 variables.add(currentVar); |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
42 // Show the panel for the variable definiton. |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
43 variables.show(); |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
44 |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
45 // Show the results. |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
46 Ext.getCmp('searchResult').show(); |
6
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
47 } |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
48 }); |
17
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
49 |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
50 |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
51 var currentVar = null; |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
52 var variables1 = { |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
53 xtype: 'panel', |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
54 id: 'variable1', |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
55 border: false, |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
56 html: 'Variablen für Abfrage 1' |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
57 }; |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
58 |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
59 var variables2 = { |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
60 xtype: 'panel', |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
61 id: 'variable2', |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
62 border: false, |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
63 html: 'Variablen für Abfrage 2' |
3eaeeec2bb28
Changed layout and added Listeners to show the correct variable definition for
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
8
diff
changeset
|
64 }; |