annotate app/controller/Status.js @ 266:f005f43007b5

Fixed issue34. Erzeuger is now a selection field for messstelle.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Mon, 29 Jul 2013 14:44:17 +0200
parents 7a4d93c9b0ff
children 841dc60824b5
rev   line source
202
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
1 Ext.define('Lada.controller.Status', {
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
2 extend: 'Ext.app.Controller',
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
3 views: [
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
4 'status.Create'
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
5 ],
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
6 stores: [
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
7 'Status'
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
8 ],
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
9 init: function() {
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
10 console.log('Initialising the Status controller');
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
11 this.control({
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
12 // CSS like selector to select element in the viewpzusatzwert. See
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
13 // ComponentQuery documentation for more details.
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
14 'statuslist': {
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
15 itemdblclick: this.editStatus
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
16 },
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
17 'statuslist toolbar button[action=add]': {
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
18 click: this.addStatus
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
19 },
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
20 'statuslist toolbar button[action=delete]': {
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
21 click: this.deleteStatus
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
22 },
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
23 'statuscreate form': {
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
24 savesuccess: this.createSuccess,
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
25 savefailure: this.createFailure
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
26 },
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
27 'statuscreate button[action=save]': {
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
28 click: this.saveStatus
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
29 },
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
30 'statusedit form': {
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
31 savesuccess: this.editSuccess,
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
32 savefailure: this.editFailure
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
33 }
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
34 });
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
35 },
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
36 saveStatus: function(button) {
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
37 console.log('Saving Status');
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
38 var form = button.up('window').down('form');
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
39 form.commit();
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
40 },
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
41 addStatus: function(button) {
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
42 console.log('Adding new Status for Messung ' + button.parentId + ' in Probe ' + button.probeId);
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
43 var zusatzwert = Ext.create('Lada.model.Status');
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
44 zusatzwert.set('probeId', button.probeId);
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
45 zusatzwert.set('messungsId', button.parentId);
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
46 var view = Ext.widget('statuscreate', {model: zusatzwert});
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
47 },
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
48 editStatus: function(grid, record) {
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
49 console.log('Editing Status');
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
50 var view = Ext.widget('statuscreate', {model: record});
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
51 console.log("Loaded Status with ID " + record.getId()); //outputs ID
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
52 },
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
53 deleteStatus: function(button) {
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
54 // Get selected item in grid
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
55 var grid = button.up('grid');
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
56 var selection = grid.getView().getSelectionModel().getSelection()[0];
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
57 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
58 if(btn === 'yes'){
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
59 var store = grid.getStore();
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
60 var deleteUrl = selection.getProxy().url + selection.getEidi();
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
61 Ext.Ajax.request({
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
62 url: deleteUrl,
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
63 method: 'DELETE',
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
64 success: function(response, opts) {
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
65 store.reload();
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
66 }
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
67 });
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
68 console.log('Deleting Kommentar');
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
69 } else {
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
70 console.log('Cancel Deleting Kommentar');
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
71 }
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
72 });
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
73 },
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
74 createSuccess: function(form, record, operation) {
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
75 // Reload store
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
76 var store = this.getStatusStore();
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
77 store.reload();
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
78 var win = form.up('window');
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
79 win.close();
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
80 },
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
81 createFailure: function(form, record, operation) {
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
82 Ext.MessageBox.show({
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
83 title: 'Fehler beim Speichern',
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
84 msg: form.message,
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
85 icon: Ext.MessageBox.ERROR,
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
86 buttons: Ext.Msg.OK
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
87 });
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
88 },
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
89 editSuccess: function(form, record, operation) {
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
90 // Reload store
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
91 var store = this.getStatusStore();
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
92 store.reload();
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
93 var win = form.up('window');
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
94 win.close();
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
95 },
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
96 editFailure: function(form, record, operation) {
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
97 Ext.MessageBox.show({
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
98 title: 'Fehler beim Speichern',
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
99 msg: form.message,
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
100 icon: Ext.MessageBox.ERROR,
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
101 buttons: Ext.Msg.OK
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
102 });
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
103 }
7a4d93c9b0ff Added status controller.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
104 });

http://lada.wald.intevation.org