Mercurial > lada > lada-client
annotate app/controller/Messungen.js @ 215:19d79b41f95d
Fixed issue22
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Mon, 15 Jul 2013 15:30:42 +0200 |
parents | 01021f00ce6a |
children | 1b5a0cb4fa6c |
rev | line source |
---|---|
108
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
1 Ext.define('Lada.controller.Messungen', { |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
2 extend: 'Ext.app.Controller', |
172
cfa0cc437781
Implemented opening a new Messungen form when clicking and the "Add Button" on
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
168
diff
changeset
|
3 views: [ |
cfa0cc437781
Implemented opening a new Messungen form when clicking and the "Add Button" on
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
168
diff
changeset
|
4 'messungen.Create' |
cfa0cc437781
Implemented opening a new Messungen form when clicking and the "Add Button" on
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
168
diff
changeset
|
5 ], |
108
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
6 stores: [ |
163
15318541e568
Added MKommentare store. Some cleanup.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
157
diff
changeset
|
7 'Messungen', |
168
79a9c1a83305
Added Messwertestore to stores.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
163
diff
changeset
|
8 'Messwerte', |
79a9c1a83305
Added Messwertestore to stores.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
163
diff
changeset
|
9 'MKommentare', |
181
062aa9001eb6
Completed Messwertelist
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
172
diff
changeset
|
10 'Status', |
062aa9001eb6
Completed Messwertelist
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
172
diff
changeset
|
11 'Messgroessen' |
108
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
12 ], |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
13 init: function() { |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
14 console.log('Initialising the Messungen controller'); |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
15 this.control({ |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
16 // CSS like selector to select element in the viewpzusatzwert. See |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
17 // ComponentQuery documentation for more details. |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
18 'messungenlist': { |
193
93de61af9b9e
Renamed function names to Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
181
diff
changeset
|
19 itemdblclick: this.editMessung |
108
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
20 }, |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
21 'messungenlist toolbar button[action=add]': { |
193
93de61af9b9e
Renamed function names to Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
181
diff
changeset
|
22 click: this.addMessung |
108
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
23 }, |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
24 'messungenlist toolbar button[action=delete]': { |
193
93de61af9b9e
Renamed function names to Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
181
diff
changeset
|
25 click: this.deleteMessung |
93de61af9b9e
Renamed function names to Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
181
diff
changeset
|
26 }, |
93de61af9b9e
Renamed function names to Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
181
diff
changeset
|
27 'messungencreate button[action=save]': { |
93de61af9b9e
Renamed function names to Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
181
diff
changeset
|
28 click: this.saveMessung |
108
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
29 }, |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
30 'messungencreate form': { |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
31 savesuccess: this.createSuccess, |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
32 savefailure: this.createFailure |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
33 }, |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
34 'messungenedit form': { |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
35 savesuccess: this.editSuccess, |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
36 savefailure: this.editFailure |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
37 } |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
38 }); |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
39 }, |
194
5d72d74a2daf
Added function to save a Messung.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
193
diff
changeset
|
40 saveMessung: function(button) { |
5d72d74a2daf
Added function to save a Messung.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
193
diff
changeset
|
41 console.log('Saving new Messung for Probe ' + button.probeId); |
5d72d74a2daf
Added function to save a Messung.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
193
diff
changeset
|
42 var form = button.up('window').down('form'); |
5d72d74a2daf
Added function to save a Messung.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
193
diff
changeset
|
43 form.commit(); |
5d72d74a2daf
Added function to save a Messung.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
193
diff
changeset
|
44 }, |
5d72d74a2daf
Added function to save a Messung.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
193
diff
changeset
|
45 addMessung: function(button) { |
172
cfa0cc437781
Implemented opening a new Messungen form when clicking and the "Add Button" on
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
168
diff
changeset
|
46 console.log('Adding new Messung for Probe ' + button.probeId); |
cfa0cc437781
Implemented opening a new Messungen form when clicking and the "Add Button" on
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
168
diff
changeset
|
47 var messung = Ext.create('Lada.model.Messung'); |
cfa0cc437781
Implemented opening a new Messungen form when clicking and the "Add Button" on
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
168
diff
changeset
|
48 messung.set('probeId', button.probeId); |
cfa0cc437781
Implemented opening a new Messungen form when clicking and the "Add Button" on
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
168
diff
changeset
|
49 var view = Ext.widget('messungencreate', {model: messung}); |
108
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
50 }, |
194
5d72d74a2daf
Added function to save a Messung.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
193
diff
changeset
|
51 editMessung: function(grid, record) { |
5d72d74a2daf
Added function to save a Messung.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
193
diff
changeset
|
52 console.log('Editing Messung'); |
108
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
53 var view = Ext.widget('messungencreate', {model: record}); |
194
5d72d74a2daf
Added function to save a Messung.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
193
diff
changeset
|
54 console.log("Loaded Messung with ID " + record.getId()); //outputs ID |
195
01021f00ce6a
Load kommentare, status and messwerte when editing probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
194
diff
changeset
|
55 |
01021f00ce6a
Load kommentare, status and messwerte when editing probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
194
diff
changeset
|
56 var kstore = this.getMKommentareStore(); |
01021f00ce6a
Load kommentare, status and messwerte when editing probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
194
diff
changeset
|
57 kstore.load({ |
01021f00ce6a
Load kommentare, status and messwerte when editing probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
194
diff
changeset
|
58 params: { |
01021f00ce6a
Load kommentare, status and messwerte when editing probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
194
diff
changeset
|
59 probeId: probeId, |
01021f00ce6a
Load kommentare, status and messwerte when editing probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
194
diff
changeset
|
60 messungsId: record.get('messungsId') |
01021f00ce6a
Load kommentare, status and messwerte when editing probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
194
diff
changeset
|
61 } |
01021f00ce6a
Load kommentare, status and messwerte when editing probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
194
diff
changeset
|
62 }); |
01021f00ce6a
Load kommentare, status and messwerte when editing probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
194
diff
changeset
|
63 var sstore = this.getStatusStore(); |
01021f00ce6a
Load kommentare, status and messwerte when editing probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
194
diff
changeset
|
64 sstore.load({ |
01021f00ce6a
Load kommentare, status and messwerte when editing probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
194
diff
changeset
|
65 params: { |
01021f00ce6a
Load kommentare, status and messwerte when editing probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
194
diff
changeset
|
66 probeId: probeId, |
01021f00ce6a
Load kommentare, status and messwerte when editing probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
194
diff
changeset
|
67 messungsId: record.get('messungsId') |
01021f00ce6a
Load kommentare, status and messwerte when editing probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
194
diff
changeset
|
68 } |
01021f00ce6a
Load kommentare, status and messwerte when editing probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
194
diff
changeset
|
69 }); |
01021f00ce6a
Load kommentare, status and messwerte when editing probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
194
diff
changeset
|
70 var mstore = this.getMessungwerteStore(); |
01021f00ce6a
Load kommentare, status and messwerte when editing probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
194
diff
changeset
|
71 mstore.load({ |
01021f00ce6a
Load kommentare, status and messwerte when editing probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
194
diff
changeset
|
72 params: { |
01021f00ce6a
Load kommentare, status and messwerte when editing probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
194
diff
changeset
|
73 probeId: probeId, |
01021f00ce6a
Load kommentare, status and messwerte when editing probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
194
diff
changeset
|
74 messungsId: record.get('messungsId') |
01021f00ce6a
Load kommentare, status and messwerte when editing probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
194
diff
changeset
|
75 } |
01021f00ce6a
Load kommentare, status and messwerte when editing probe.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
194
diff
changeset
|
76 }); |
108
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
77 }, |
194
5d72d74a2daf
Added function to save a Messung.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
193
diff
changeset
|
78 deleteMessung: function(button) { |
108
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
79 // Get selected item in grid |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
80 var grid = button.up('grid'); |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
81 var selection = grid.getView().getSelectionModel().getSelection()[0]; |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
82 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){ |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
83 if(btn === 'yes'){ |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
84 var store = grid.getStore(); |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
85 store.remove(selection); |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
86 store.sync(); |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
87 console.log('Deleting Kommentar'); |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
88 } else { |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
89 console.log('Cancel Deleting Kommentar'); |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
90 } |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
91 }); |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
92 }, |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
93 createSuccess: function(form, record, operation) { |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
94 // Reload store |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
95 var store = this.getMessungenStore(); |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
96 store.reload(); |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
97 var win = form.up('window'); |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
98 win.close(); |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
99 }, |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
100 createFailure: function(form, record, operation) { |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
101 Ext.MessageBox.show({ |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
102 title: 'Fehler beim Speichern', |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
103 msg: form.message, |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
104 icon: Ext.MessageBox.ERROR, |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
105 buttons: Ext.Msg.OK |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
106 }); |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
107 }, |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
108 editSuccess: function(form, record, operation) { |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
109 // Reload store |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
110 var store = this.getMessungenStore(); |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
111 store.reload(); |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
112 var win = form.up('window'); |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
113 win.close(); |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
114 }, |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
115 editFailure: function(form, record, operation) { |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
116 Ext.MessageBox.show({ |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
117 title: 'Fehler beim Speichern', |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
118 msg: form.message, |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
119 icon: Ext.MessageBox.ERROR, |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
120 buttons: Ext.Msg.OK |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
121 }); |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
122 } |
6c69bbb61c65
Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
123 }); |