Mercurial > lada > lada-client
annotate app/controller/Proben.js @ 52:af418743e1f4
Load Proben form with detailed version of the proben record.
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Mon, 27 May 2013 14:59:59 +0200 |
parents | 230bac063b0b |
children | 73bc17de6ff2 |
rev | line source |
---|---|
1
af8d7217521d
Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
1 Ext.define('Lada.controller.Proben', { |
af8d7217521d
Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
2 extend: 'Ext.app.Controller', |
4
b8e56e880f02
Added a first example view (userlisting) from the EXJS Tutorial. Need to be
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
1
diff
changeset
|
3 views: [ |
18
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
4 'proben.List', |
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
5 'proben.Edit' |
4
b8e56e880f02
Added a first example view (userlisting) from the EXJS Tutorial. Need to be
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
1
diff
changeset
|
6 ], |
13
a8efc4b96888
Added model for Proben and a Store.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
5
diff
changeset
|
7 stores: [ |
40
f9b6de636ad0
Added probenart combobox
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
18
diff
changeset
|
8 'Proben', |
42
5ed477590736
Added missiong code for uwb.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
41
diff
changeset
|
9 'Uwb', |
41
a1be7ccd4d0c
Added datenbasis combobox
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
40
diff
changeset
|
10 'Datenbasis', |
46
39f5f1529847
Added combotbox for Betriebsart.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
42
diff
changeset
|
11 'Probenart', |
49
792c34b3f5a9
Added combobox for field "testdatensatz"
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
46
diff
changeset
|
12 'Betriebsart', |
792c34b3f5a9
Added combobox for field "testdatensatz"
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
46
diff
changeset
|
13 'Testdatensatz' |
13
a8efc4b96888
Added model for Proben and a Store.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
5
diff
changeset
|
14 ], |
a8efc4b96888
Added model for Proben and a Store.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
5
diff
changeset
|
15 models: [ |
a8efc4b96888
Added model for Proben and a Store.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
5
diff
changeset
|
16 'Probe' |
a8efc4b96888
Added model for Proben and a Store.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
5
diff
changeset
|
17 ], |
1
af8d7217521d
Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
18 init: function() { |
af8d7217521d
Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
19 console.log('Initialising the Proben controller'); |
af8d7217521d
Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
20 this.control({ |
af8d7217521d
Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
21 // CSS like selector to select element in the viewport. See |
af8d7217521d
Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
22 // ComponentQuery documentation for more details. |
18
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
23 'probenlist': { |
1
af8d7217521d
Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
24 // Map the "render" event to the given function. |
5
039584709fa7
Map double click event on rows of the userlist to the editProben function.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
4
diff
changeset
|
25 render: this.onPanelRendered, |
039584709fa7
Map double click event on rows of the userlist to the editProben function.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
4
diff
changeset
|
26 // Map Doubleclick on rows of the probenlist. |
039584709fa7
Map double click event on rows of the userlist to the editProben function.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
4
diff
changeset
|
27 itemdblclick: this.editProbe |
18
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
28 }, |
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
29 'probenedit button[action=save]': { |
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
30 click: this.updateProbe |
1
af8d7217521d
Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
31 } |
af8d7217521d
Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
32 }); |
af8d7217521d
Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
33 }, |
af8d7217521d
Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
34 onPanelRendered: function() { |
af8d7217521d
Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
35 console.log('The panel was rendered'); |
5
039584709fa7
Map double click event on rows of the userlist to the editProben function.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
4
diff
changeset
|
36 }, |
039584709fa7
Map double click event on rows of the userlist to the editProben function.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
4
diff
changeset
|
37 editProbe: function(grid, record) { |
51
230bac063b0b
Fixed debug output of the selected probe on doubleclick in grid.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
49
diff
changeset
|
38 console.log('Double click on ' + record.get('probeId')); |
18
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
39 // Create new window to edit the seletced record. |
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
40 var view = Ext.widget('probenedit'); |
52
af418743e1f4
Load Proben form with detailed version of the proben record.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
51
diff
changeset
|
41 //console.log(Ext.ModelManager.getModel('Lada.model.Probe')); |
af418743e1f4
Load Proben form with detailed version of the proben record.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
51
diff
changeset
|
42 Ext.ModelManager.getModel('Lada.model.Probe').load(record.get('probeId'), { |
af418743e1f4
Load Proben form with detailed version of the proben record.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
51
diff
changeset
|
43 success: function(record) { |
af418743e1f4
Load Proben form with detailed version of the proben record.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
51
diff
changeset
|
44 view.down('form').loadRecord(record); |
af418743e1f4
Load Proben form with detailed version of the proben record.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
51
diff
changeset
|
45 console.log("Loaded probe with ID " + record.getId()); //outputs ID |
af418743e1f4
Load Proben form with detailed version of the proben record.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
51
diff
changeset
|
46 } |
af418743e1f4
Load Proben form with detailed version of the proben record.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
51
diff
changeset
|
47 }); |
18
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
48 }, |
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
49 updateProbe: function(button) { |
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
50 console.log('Click save'); |
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
51 // We only have a reference to the button here but we really wnat to |
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
52 // get the form and the window. So first get the window and form and |
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
53 // the the record an values. |
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
54 var win = button.up('window'); |
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
55 var form = win.down('form'); |
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
56 var record = form.getRecord(); |
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
57 var values = form.getValues(); |
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
58 |
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
59 record.set(values); |
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
60 win.close(); |
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
61 // synchronize the store after editing the record |
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
62 // NOTE: The function 'getProbenStore' will be generated |
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
63 // dynamically based on the Name of the configured Store!!! |
9e1a40312bbe
Implemented a basic edit dialog. Data will be set to data/proben2.json url
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
13
diff
changeset
|
64 this.getProbenStore().sync(); |
1
af8d7217521d
Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
65 } |
af8d7217521d
Added basic Proben controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
66 }); |