annotate app/controller/Messwert.js @ 217:4db982514a5f

Fixed issue21
author Torsten Irländer <torsten.irlaender@intevation.de>
date Mon, 15 Jul 2013 16:30:52 +0200
parents f0c59e7ee0bc
children 82f8b5638f26
rev   line source
197
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
1 Ext.define('Lada.controller.Messwert', {
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
2 extend: 'Ext.app.Controller',
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
3 views: [
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
4 'messwerte.Create'
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
5 ],
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
6 stores: [
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
7 'Messungen',
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
8 'Messwerte',
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
9 'Messeinheit',
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
10 'Messgroessen'
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
11 ],
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
12 init: function() {
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
13 console.log('Initialising the Messungen controller');
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
14 this.control({
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
15 // CSS like selector to select element in the viewpzusatzwert. See
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
16 // ComponentQuery documentation for more details.
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
17 'messwertelist': {
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
18 itemdblclick: this.editMesswert
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
19 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
20 'messwertelist toolbar button[action=add]': {
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
21 click: this.addMesswert
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
22 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
23 'messwertelist toolbar button[action=delete]': {
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
24 click: this.deleteMesswert
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
25 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
26 'messwertecreate button[action=save]': {
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
27 click: this.saveMesswert
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
28 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
29 'messwertecreate form': {
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
30 savesuccess: this.createSuccess,
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
31 savefailure: this.createFailure
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
32 }
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
33 });
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
34 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
35 saveMesswert: function(button) {
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
36 console.log('Saving MesswerMesswert');
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
37 var form = button.up('window').down('form');
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
38 form.commit();
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
39 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
40 addMesswert: function(button) {
213
f0c59e7ee0bc Set messungsid for new messungunswerte
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 197
diff changeset
41 console.log('Adding new Messwert for Messung ' + button.parentId + ' for Probe ' + button.probeId);
197
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
42 var messung = Ext.create('Lada.model.Messwert');
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
43 messung.set('probeId', button.probeId);
213
f0c59e7ee0bc Set messungsid for new messungunswerte
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 197
diff changeset
44 messung.set('messungsId', button.parentId);
197
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
45 var view = Ext.widget('messwertecreate', {model: messung});
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
46 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
47 editMesswert: function(grid, record) {
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
48 console.log('Editing Messwert');
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
49 var view = Ext.widget('messwertecreate', {model: record});
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
50 console.log("Loaded Messwert with ID " + record.getId()); //outputs ID
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
51 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
52 deleteMesswert: function(button) {
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
53 // Get selected item in grid
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
54 var grid = button.up('grid');
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
55 var selection = grid.getView().getSelectionModel().getSelection()[0];
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
56 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
57 if(btn === 'yes'){
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
58 var store = grid.getStore();
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
59 store.remove(selection);
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
60 store.sync();
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
61 console.log('Deleting Kommentar');
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
62 } else {
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
63 console.log('Cancel Deleting Kommentar');
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
64 }
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
65 });
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
66 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
67 createSuccess: function(form, record, operation) {
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
68 // Reload store
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
69 var store = this.getMessungenStore();
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
70 store.reload();
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
71 var win = form.up('window');
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
72 win.close();
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
73 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
74 createFailure: function(form, record, operation) {
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
75 Ext.MessageBox.show({
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
76 title: 'Fehler beim Speichern',
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
77 msg: form.message,
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
78 icon: Ext.MessageBox.ERROR,
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
79 buttons: Ext.Msg.OK
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
80 });
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
81 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
82 editSuccess: function(form, record, operation) {
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
83 // Reload store
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
84 var store = this.getMessungenStore();
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
85 store.reload();
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
86 var win = form.up('window');
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
87 win.close();
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
88 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
89 editFailure: function(form, record, operation) {
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
90 Ext.MessageBox.show({
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
91 title: 'Fehler beim Speichern',
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
92 msg: form.message,
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
93 icon: Ext.MessageBox.ERROR,
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
94 buttons: Ext.Msg.OK
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
95 });
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
96 }
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
97 });

http://lada.wald.intevation.org