annotate app/controller/Messwert.js @ 286:c509e9f6d4db

Added BaseController and inherit Kommentar controller from it.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Fri, 09 Aug 2013 14:21:08 +0200
parents c32be5f97b5d
children fe51239321d9
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: [
284
c32be5f97b5d Fix for issue58. Get the related probe for the messwert and check if the probe
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 219
diff changeset
7 'Proben',
197
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
8 'Messungen',
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
9 'Messwerte',
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
10 'Messeinheit',
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
11 'Messgroessen'
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
12 ],
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
13 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
14 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
15 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
16 // 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
17 // 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
18 'messwertelist': {
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
19 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
20 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
21 '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
22 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
23 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
24 '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
25 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
26 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
27 '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
28 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
29 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
30 '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
31 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
32 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
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 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
36 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
37 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
38 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
39 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
40 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
41 addMesswert: function(button) {
213
f0c59e7ee0bc Set messungsid for new messungunswerte
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 197
diff changeset
42 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
43 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
44 messung.set('probeId', button.probeId);
213
f0c59e7ee0bc Set messungsid for new messungunswerte
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 197
diff changeset
45 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
46 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
47 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
48 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
49 console.log('Editing Messwert');
284
c32be5f97b5d Fix for issue58. Get the related probe for the messwert and check if the probe
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 219
diff changeset
50 var probe = this.getProbenStore().getById(record.get('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
51 var view = Ext.widget('messwertecreate', {model: record});
284
c32be5f97b5d Fix for issue58. Get the related probe for the messwert and check if the probe
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 219
diff changeset
52 if (probe.get('readonly') === true) {
c32be5f97b5d Fix for issue58. Get the related probe for the messwert and check if the probe
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 219
diff changeset
53 var form = view.down('form');
c32be5f97b5d Fix for issue58. Get the related probe for the messwert and check if the probe
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 219
diff changeset
54 form.setReadOnly(true);
c32be5f97b5d Fix for issue58. Get the related probe for the messwert and check if the probe
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 219
diff changeset
55 }
c32be5f97b5d Fix for issue58. Get the related probe for the messwert and check if the probe
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 219
diff changeset
56
197
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
57 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
58 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
59 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
60 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
61 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
62 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
63 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
64 var store = grid.getStore();
219
82f8b5638f26 Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 213
diff changeset
65 var deleteUrl = selection.getProxy().url + selection.getEidi();
82f8b5638f26 Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 213
diff changeset
66 Ext.Ajax.request({
82f8b5638f26 Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 213
diff changeset
67 url: deleteUrl,
82f8b5638f26 Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 213
diff changeset
68 method: 'DELETE',
82f8b5638f26 Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 213
diff changeset
69 success: function(response, opts) {
82f8b5638f26 Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 213
diff changeset
70 store.reload();
82f8b5638f26 Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 213
diff changeset
71 }
82f8b5638f26 Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 213
diff changeset
72 });
82f8b5638f26 Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 213
diff changeset
73 console.log('Deleting Messwert');
197
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
74 } else {
219
82f8b5638f26 Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 213
diff changeset
75 console.log('Cancel Deleting Messwert');
197
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
76 }
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
77 });
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
78 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
79 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
80 // 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
81 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
82 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
83 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
84 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
85 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
86 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
87 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
88 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
89 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
90 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
91 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
92 });
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
93 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
94 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
95 // 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
96 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
97 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
98 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
99 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
100 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
101 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
102 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
103 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
104 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
105 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
106 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
107 });
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
108 }
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
109 });

http://lada.wald.intevation.org