annotate app/controller/Messungen.js @ 178:c53f3110852e

Added Messmethode.js
author Torsten Irländer <torsten.irlaender@intevation.de>
date Thu, 04 Jul 2013 11:24:02 +0200
parents cfa0cc437781
children 062aa9001eb6
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',
79a9c1a83305 Added Messwertestore to stores.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 163
diff changeset
10 'Status'
108
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
11 ],
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
12 init: function() {
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
13 console.log('Initialising the Messungen controller');
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
14 this.control({
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
15 // 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
16 // ComponentQuery documentation for more details.
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
17 'messungenlist': {
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
18 itemdblclick: this.editZusatzwert
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
19 },
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
20 'messungenlist toolbar button[action=add]': {
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
21 click: this.addZusatzwert
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
22 },
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
23 'messungenlist toolbar button[action=delete]': {
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
24 click: this.deleteZusatzwert
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
25 },
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
26 'messungencreate form': {
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
27 savesuccess: this.createSuccess,
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
28 savefailure: this.createFailure
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 'messungenedit form': {
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
31 savesuccess: this.editSuccess,
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
32 savefailure: this.editFailure
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 });
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
35 },
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
36 addZusatzwert: 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
37 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
38 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
39 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
40 var view = Ext.widget('messungencreate', {model: messung});
108
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
41 },
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
42 editZusatzwert: function(grid, record) {
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
43 console.log('Editing Zusatzwert');
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
44 var view = Ext.widget('messungencreate', {model: record});
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
45 console.log("Loaded Zusatzwert with ID " + record.getId()); //outputs ID
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
46 },
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
47 deleteZusatzwert: function(button) {
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
48 // Get selected item in grid
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
49 var grid = button.up('grid');
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
50 var selection = grid.getView().getSelectionModel().getSelection()[0];
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
51 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
52 if(btn === 'yes'){
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
53 var store = grid.getStore();
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
54 store.remove(selection);
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
55 store.sync();
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
56 console.log('Deleting Kommentar');
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
57 } else {
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
58 console.log('Cancel Deleting Kommentar');
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
59 }
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
60 });
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
61 },
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
62 createSuccess: function(form, record, operation) {
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
63 // Reload store
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
64 var store = this.getMessungenStore();
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
65 store.reload();
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
66 var win = form.up('window');
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
67 win.close();
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
68 },
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
69 createFailure: function(form, record, operation) {
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
70 Ext.MessageBox.show({
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
71 title: 'Fehler beim Speichern',
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
72 msg: form.message,
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
73 icon: Ext.MessageBox.ERROR,
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
74 buttons: Ext.Msg.OK
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
75 });
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
76 },
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
77 editSuccess: function(form, record, operation) {
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
78 // Reload store
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
79 var store = this.getMessungenStore();
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
80 store.reload();
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
81 var win = form.up('window');
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
82 win.close();
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
83 },
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
84 editFailure: function(form, record, operation) {
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
85 Ext.MessageBox.show({
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
86 title: 'Fehler beim Speichern',
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
87 msg: form.message,
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
88 icon: Ext.MessageBox.ERROR,
6c69bbb61c65 Added Forms to add Messungen
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
89 buttons: Ext.Msg.OK
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 });

http://lada.wald.intevation.org