Mercurial > lada > lada-client
annotate app/controller/Messwert.js @ 270:0d6552bb28ea
Add cancel Button to the editproben window and only show save button if the
form is actually writeable.
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Tue, 06 Aug 2013 14:33:14 +0200 |
parents | 82f8b5638f26 |
children | c32be5f97b5d |
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 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(); |
219
82f8b5638f26
Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
213
diff
changeset
|
58 var deleteUrl = selection.getProxy().url + selection.getEidi(); |
82f8b5638f26
Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
213
diff
changeset
|
59 Ext.Ajax.request({ |
82f8b5638f26
Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
213
diff
changeset
|
60 url: deleteUrl, |
82f8b5638f26
Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
213
diff
changeset
|
61 method: 'DELETE', |
82f8b5638f26
Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
213
diff
changeset
|
62 success: function(response, opts) { |
82f8b5638f26
Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
213
diff
changeset
|
63 store.reload(); |
82f8b5638f26
Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
213
diff
changeset
|
64 } |
82f8b5638f26
Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
213
diff
changeset
|
65 }); |
82f8b5638f26
Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
213
diff
changeset
|
66 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
|
67 } else { |
219
82f8b5638f26
Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
213
diff
changeset
|
68 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
|
69 } |
748614e867b1
Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
70 }); |
748614e867b1
Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
71 }, |
748614e867b1
Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
72 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
|
73 // 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
|
74 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
|
75 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
|
76 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
|
77 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
|
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 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
|
80 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
|
81 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
|
82 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
|
83 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
|
84 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
|
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 }, |
748614e867b1
Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
87 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
|
88 // 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
|
89 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
|
90 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
|
91 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
|
92 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
|
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 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
|
95 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
|
96 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
|
97 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
|
98 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
|
99 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
|
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 } |
748614e867b1
Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
102 }); |