annotate app/controller/Messwert.js @ 309:51897f9a6bbb

Use ts2date function from lib.Helpers. Remove old code
author Torsten Irländer <torsten.irlaender@intevation.de>
date Fri, 09 Aug 2013 15:24:00 +0200
parents fe51239321d9
children 6a7a9267e00f
rev   line source
290
fe51239321d9 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 284
diff changeset
1 /**
fe51239321d9 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 284
diff changeset
2 * Controller for Messwerte
fe51239321d9 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 284
diff changeset
3 */
197
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
4 Ext.define('Lada.controller.Messwert', {
290
fe51239321d9 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 284
diff changeset
5 extend: 'Lada.controller.Base',
197
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
6 views: [
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
7 '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
8 ],
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
9 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
10 '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
11 'Messungen',
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
12 'Messwerte',
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
13 'Messeinheit',
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
14 'Messgroessen'
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
15 ],
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
16 init: function() {
290
fe51239321d9 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 284
diff changeset
17 console.log('Initialising the Messwert controller');
fe51239321d9 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 284
diff changeset
18 this.callParent();
fe51239321d9 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 284
diff changeset
19 },
fe51239321d9 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 284
diff changeset
20 addListeners: function() {
197
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
21 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
22 'messwertelist': {
290
fe51239321d9 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 284
diff changeset
23 itemdblclick: this.editItem
197
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
24 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
25 'messwertelist toolbar button[action=add]': {
290
fe51239321d9 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 284
diff changeset
26 click: this.addItem
197
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
27 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
28 'messwertelist toolbar button[action=delete]': {
290
fe51239321d9 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 284
diff changeset
29 click: this.deleteItem
197
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
30 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
31 'messwertecreate button[action=save]': {
290
fe51239321d9 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 284
diff changeset
32 click: this.saveItem
197
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 '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
35 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
36 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
37 }
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
38 });
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
39 },
290
fe51239321d9 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 284
diff changeset
40 saveItem: function(button) {
197
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('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
42 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
43 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
44 },
290
fe51239321d9 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 284
diff changeset
45 addItem: function(button) {
213
f0c59e7ee0bc Set messungsid for new messungunswerte
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 197
diff changeset
46 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
47 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
48 messung.set('probeId', button.probeId);
213
f0c59e7ee0bc Set messungsid for new messungunswerte
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 197
diff changeset
49 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
50 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
51 },
290
fe51239321d9 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 284
diff changeset
52 editItem: function(grid, record) {
197
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
53 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
54 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
55 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
56 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
57 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
58 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
59 }
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
60
197
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("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
62 },
290
fe51239321d9 Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 284
diff changeset
63 deleteItem: function(button) {
197
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 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
65 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
66 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
67 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
68 var store = grid.getStore();
219
82f8b5638f26 Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 213
diff changeset
69 var deleteUrl = selection.getProxy().url + selection.getEidi();
82f8b5638f26 Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 213
diff changeset
70 Ext.Ajax.request({
82f8b5638f26 Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 213
diff changeset
71 url: deleteUrl,
82f8b5638f26 Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 213
diff changeset
72 method: 'DELETE',
82f8b5638f26 Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 213
diff changeset
73 success: function(response, opts) {
82f8b5638f26 Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 213
diff changeset
74 store.reload();
82f8b5638f26 Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 213
diff changeset
75 }
82f8b5638f26 Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 213
diff changeset
76 });
82f8b5638f26 Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 213
diff changeset
77 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
78 } else {
219
82f8b5638f26 Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 213
diff changeset
79 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
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 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
83 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
84 // 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
85 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
86 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
87 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
88 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
89 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
90 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
91 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
92 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
93 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
94 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
95 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
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 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
98 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
99 // 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
100 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
101 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
102 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
103 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
104 },
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
105 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
106 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
107 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
108 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
109 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
110 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
111 });
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
112 }
748614e867b1 Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
113 });

http://lada.wald.intevation.org