Mercurial > lada > lada-client
annotate app/controller/Messwert.js @ 488:f7446ebfe5d0
Added and updated models.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Fri, 31 Oct 2014 21:10:35 +0100 |
parents | debfcc7713e3 |
children | 446e99cfd425 |
rev | line source |
---|---|
472
debfcc7713e3
Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
453
diff
changeset
|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz |
debfcc7713e3
Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
453
diff
changeset
|
2 * Software engineering by Intevation GmbH |
debfcc7713e3
Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
453
diff
changeset
|
3 * |
debfcc7713e3
Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
453
diff
changeset
|
4 * This file is Free Software under the GNU GPL (v>=3) |
debfcc7713e3
Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
453
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out |
debfcc7713e3
Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
453
diff
changeset
|
6 * the documentation coming with IMIS-Labordaten-Application for details. |
debfcc7713e3
Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
453
diff
changeset
|
7 */ |
debfcc7713e3
Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
453
diff
changeset
|
8 |
290
fe51239321d9
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
284
diff
changeset
|
9 /** |
fe51239321d9
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
284
diff
changeset
|
10 * Controller for Messwerte |
fe51239321d9
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
284
diff
changeset
|
11 */ |
197
748614e867b1
Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
12 Ext.define('Lada.controller.Messwert', { |
290
fe51239321d9
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
284
diff
changeset
|
13 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
|
14 views: [ |
748614e867b1
Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
15 '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
|
16 ], |
748614e867b1
Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
17 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
|
18 '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
|
19 'Messungen', |
748614e867b1
Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
20 'Messwerte', |
748614e867b1
Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
21 'Messeinheit', |
748614e867b1
Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
22 'Messgroessen' |
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 init: function() { |
290
fe51239321d9
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
284
diff
changeset
|
25 console.log('Initialising the Messwert controller'); |
fe51239321d9
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
284
diff
changeset
|
26 this.callParent(); |
fe51239321d9
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
284
diff
changeset
|
27 }, |
fe51239321d9
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
284
diff
changeset
|
28 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
|
29 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
|
30 'messwertelist': { |
290
fe51239321d9
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
284
diff
changeset
|
31 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
|
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 'messwertelist toolbar button[action=add]': { |
290
fe51239321d9
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
284
diff
changeset
|
34 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
|
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 'messwertelist toolbar button[action=delete]': { |
290
fe51239321d9
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
284
diff
changeset
|
37 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
|
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 'messwertecreate button[action=save]': { |
290
fe51239321d9
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
284
diff
changeset
|
40 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
|
41 }, |
748614e867b1
Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
42 '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
|
43 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
|
44 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
|
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 }); |
748614e867b1
Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
47 }, |
290
fe51239321d9
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
284
diff
changeset
|
48 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
|
49 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
|
50 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
|
51 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
|
52 }, |
290
fe51239321d9
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
284
diff
changeset
|
53 addItem: function(button) { |
213
f0c59e7ee0bc
Set messungsid for new messungunswerte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
197
diff
changeset
|
54 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
|
55 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
|
56 messung.set('probeId', button.probeId); |
213
f0c59e7ee0bc
Set messungsid for new messungunswerte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
197
diff
changeset
|
57 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
|
58 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
|
59 }, |
290
fe51239321d9
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
284
diff
changeset
|
60 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
|
61 console.log('Editing Messwert'); |
453
2b886fc38282
Formatting
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
362
diff
changeset
|
62 record.getAuthInfo(this.initEditWindow); |
362
6a7a9267e00f
Issue56: Changed way how to set the form and window to readonly. Now all dialogs should
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
290
diff
changeset
|
63 console.log("Loaded Messwert with ID " + record.getId()); //outputs ID |
6a7a9267e00f
Issue56: Changed way how to set the form and window to readonly. Now all dialogs should
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
290
diff
changeset
|
64 }, |
6a7a9267e00f
Issue56: Changed way how to set the form and window to readonly. Now all dialogs should
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
290
diff
changeset
|
65 initEditWindow: function(record, readonly, owner) { |
197
748614e867b1
Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
66 var view = Ext.widget('messwertecreate', {model: record}); |
362
6a7a9267e00f
Issue56: Changed way how to set the form and window to readonly. Now all dialogs should
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
290
diff
changeset
|
67 var ignore = Array(); |
6a7a9267e00f
Issue56: Changed way how to set the form and window to readonly. Now all dialogs should
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
290
diff
changeset
|
68 if (readonly) { |
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
|
69 var form = view.down('form'); |
362
6a7a9267e00f
Issue56: Changed way how to set the form and window to readonly. Now all dialogs should
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
290
diff
changeset
|
70 form.setReadOnly(true, ignore); |
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
|
71 } |
197
748614e867b1
Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
72 }, |
290
fe51239321d9
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
284
diff
changeset
|
73 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
|
74 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
|
75 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
|
76 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
|
77 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
|
78 var store = grid.getStore(); |
219
82f8b5638f26
Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
213
diff
changeset
|
79 var deleteUrl = selection.getProxy().url + selection.getEidi(); |
82f8b5638f26
Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
213
diff
changeset
|
80 Ext.Ajax.request({ |
82f8b5638f26
Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
213
diff
changeset
|
81 url: deleteUrl, |
82f8b5638f26
Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
213
diff
changeset
|
82 method: 'DELETE', |
82f8b5638f26
Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
213
diff
changeset
|
83 success: function(response, opts) { |
82f8b5638f26
Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
213
diff
changeset
|
84 store.reload(); |
82f8b5638f26
Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
213
diff
changeset
|
85 } |
82f8b5638f26
Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
213
diff
changeset
|
86 }); |
82f8b5638f26
Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
213
diff
changeset
|
87 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
|
88 } else { |
219
82f8b5638f26
Fixed delete call
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
213
diff
changeset
|
89 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
|
90 } |
748614e867b1
Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
91 }); |
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 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
|
94 // Reload store |
453
2b886fc38282
Formatting
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
362
diff
changeset
|
95 var store = this.getMesswerteStore(); |
197
748614e867b1
Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
96 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
|
97 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
|
98 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
|
99 }, |
748614e867b1
Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
100 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
|
101 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
|
102 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
|
103 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
|
104 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
|
105 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
|
106 }); |
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 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
|
109 // Reload store |
453
2b886fc38282
Formatting
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
362
diff
changeset
|
110 var store = this.getMesswerteStore(); |
197
748614e867b1
Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
111 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
|
112 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
|
113 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
|
114 }, |
748614e867b1
Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
115 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
|
116 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
|
117 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
|
118 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
|
119 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
|
120 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
|
121 }); |
748614e867b1
Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
122 } |
748614e867b1
Added messwerte controller to be able to add, edit and delete messwerte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
123 }); |