comparison app/controller/form/Messprogramm.js @ 1289:bfdc00c24baf

Ortszuordnung for messprogramm and probe using same form
author Maximilian Krambach <mkrambach@intevation.de>
date Wed, 01 Feb 2017 14:52:51 +0100
parents 3b4dcc83a21b
children 2e462c5334f1
comparison
equal deleted inserted replaced
1288:08085b7d1d0b 1289:bfdc00c24baf
10 * A Controller for a Messprogramm form 10 * A Controller for a Messprogramm form
11 */ 11 */
12 Ext.define('Lada.controller.form.Messprogramm', { 12 Ext.define('Lada.controller.form.Messprogramm', {
13 extend: 'Ext.app.Controller', 13 extend: 'Ext.app.Controller',
14 14
15 requires: [
16 'Lada.view.window.MessprogrammOrt'
17 ],
18 15
19 /** 16 /**
20 * Initialize the Controller 17 * Initialize the Controller
21 */ 18 */
22 init: function() { 19 init: function() {
25 click: this.save 22 click: this.save
26 }, 23 },
27 'messprogrammform button[action=discard]': { 24 'messprogrammform button[action=discard]': {
28 click: this.discard 25 click: this.discard
29 }, 26 },
30 'messprogrammform button[action=ort]': {
31 click: this.editOrtWindow
32 },
33 'messprogrammform': { 27 'messprogrammform': {
34 dirtychange: this.dirtyForm 28 dirtychange: this.dirtyForm
35 }, 29 },
36 'messprogrammform messstellelabor combobox': { 30 'messprogrammform messstellelabor combobox': {
37 select: this.setNetzbetreiber 31 select: this.setNetzbetreiber
38 },
39 'messprogrammform location combobox': {
40 select: this.syncOrtWindow
41 }, 32 },
42 'messprogrammform numfield numberfield': { 33 'messprogrammform numfield numberfield': {
43 change: this.checkPeriod 34 change: this.checkPeriod
44 }, 35 },
45 'messprogrammform [name="teilintervallVon"]': { 36 'messprogrammform [name="teilintervallVon"]': {
119 } 110 }
120 } 111 }
121 }, 112 },
122 113
123 /** 114 /**
124 * The function will open a new Window to edit the Ort of a Messprogramm
125 */
126 editOrtWindow: function(button) {
127 var formPanel = button.up('form');
128 //Only Open if the WIndow does not exist, else focus
129 if (!formPanel.ortWindow) {
130 var data = formPanel.getForm().getFieldValues(true);
131 formPanel.ortWindow = Ext.create('Lada.view.window.MessprogrammOrt', {
132 record: formPanel.getRecord(),
133 parentWindow: formPanel.up('window')
134 });
135 formPanel.ortWindow.show();
136 formPanel.ortWindow.initData();
137 }
138 else {
139 formPanel.ortWindow.focus();
140 formPanel.ortWindow.setActive(true);
141 }
142 },
143
144 /**
145 * When a OrtWindow exist, and the value of the location combobox is changed, update the window.
146 */
147 syncOrtWindow: function(combo, record){
148 var formPanel = combo.up('messprogrammform');
149 if (formPanel.ortWindow) {
150 var ortwindowlocation = formPanel
151 .ortWindow.down('location')
152 var ortwindowcombo = ortwindowlocation
153 .down('combobox');
154
155 ortwindowcombo.select(combo.getValue());
156 ortwindowlocation.fireEvent('select',
157 ortwindowcombo, ortwindowcombo.record);
158 }
159 },
160
161 /**
162 * When the Slider was used, 115 * When the Slider was used,
163 * update the Value of the Teilintervallfields 116 * update the Value of the Teilintervallfields
164 */ 117 */
165 synchronizeFields: function(slider, newValue, thumb) { 118 synchronizeFields: function(slider, newValue, thumb) {
166 var formPanel = slider.up('form'); 119 var formPanel = slider.up('form');
200 */ 153 */
201 save: function(button) { 154 save: function(button) {
202 var formPanel = button.up('form'); 155 var formPanel = button.up('form');
203 var data = formPanel.getForm().getFieldValues(); 156 var data = formPanel.getForm().getFieldValues();
204 var orte = Ext.data.StoreManager.get('orte'); 157 var orte = Ext.data.StoreManager.get('orte');
205 var gemId;
206 if (data['ortId'] !== null && data['ortId'] !== '') {
207 gemId = orte.getById(data['ortId']).get('gemId');
208 }
209 for (var key in data) { 158 for (var key in data) {
210 formPanel.getForm().getRecord().set(key, data[key]); 159 formPanel.getForm().getRecord().set(key, data[key]);
211 } 160 }
212 formPanel.getForm().getRecord().set('gemId', gemId);
213 if (!formPanel.getForm().getRecord().get('letzteAenderung')) { 161 if (!formPanel.getForm().getRecord().get('letzteAenderung')) {
214 formPanel.getForm().getRecord().data.letzteAenderung = new Date(); 162 formPanel.getForm().getRecord().data.letzteAenderung = new Date();
215 } 163 }
216 formPanel.getForm().getRecord().save({ 164 formPanel.getForm().getRecord().save({
217 success: function(record, response) { 165 success: function(record, response) {
400 for (var i = field.layer + 1; i < 12; i++) { 348 for (var i = field.layer + 1; i < 12; i++) {
401 allS[i].clearValue(); 349 allS[i].clearValue();
402 } 350 }
403 } 351 }
404 352
405
406 }); 353 });

http://lada.wald.intevation.org