annotate app/controller/Messwert.js @ 202:7a4d93c9b0ff

Added status controller.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Mon, 08 Jul 2013 16:16:39 +0200
parents 748614e867b1
children f0c59e7ee0bc
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) {
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
41 console.log('Adding new Messung for Probe ' + button.probeId);
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);
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
44 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
45 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
46 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
47 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
48 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
49 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
50 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
51 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
52 // 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
53 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
54 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
55 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
56 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
57 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
58 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
59 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
60 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
61 } else {
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
62 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
63 }
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 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
67 // 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
68 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
69 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
70 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
71 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
72 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
73 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
74 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
75 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
76 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
77 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
78 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
79 });
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 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
82 // 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
83 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
84 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
85 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
86 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
87 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
88 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
89 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
90 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
91 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
92 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
93 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
94 });
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 });

http://lada.wald.intevation.org