Mercurial > lada > lada-client
comparison app/view/form/Messprogramm.js @ 757:b8502964f5c3
Added missing files. Added MmtMockup
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Wed, 06 May 2015 14:15:37 +0200 |
parents | |
children | b7484c7da2d4 |
comparison
equal
deleted
inserted
replaced
756:f2db1ae1d012 | 757:b8502964f5c3 |
---|---|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU GPL (v>=3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out | |
6 * the documentation coming with IMIS-Labordaten-Application for details. | |
7 */ | |
8 | |
9 /* | |
10 * Formular to edit a Messprogramm | |
11 */ | |
12 Ext.define('Lada.view.form.Messprogramm', { | |
13 extend: 'Ext.form.Panel', | |
14 alias: 'widget.messprogrammform', | |
15 requires: [ | |
16 'Lada.view.widget.Datenbasis', | |
17 'Lada.view.widget.Messstelle', | |
18 'Lada.view.widget.Netzbetreiber', | |
19 'Lada.view.widget.Betriebsart', | |
20 'Lada.view.widget.Testdatensatz', | |
21 'Lada.view.widget.Probenart', | |
22 'Lada.view.widget.Umwelt', | |
23 'Lada.view.widget.base.TextField', | |
24 'Lada.view.widget.base.FieldSet', | |
25 'Lada.model.Messprogramm', | |
26 'Lada.model.MmtMessprogramm', | |
27 'Lada.view.widget.Probenintervall', | |
28 'Lada.view.widget.ProbenintervallSlider', | |
29 'Lada.view.widget.base.Datetime', | |
30 'Lada.view.widget.base.DateField' | |
31 ], | |
32 | |
33 model: 'Lada.model.Messprogramm', | |
34 minWidth: 650, | |
35 margin: 5, | |
36 border: 0, | |
37 | |
38 recordId: null, | |
39 | |
40 trackResetOnLoad: true, | |
41 | |
42 initComponent: function() { | |
43 var me = this; | |
44 var i18n = Lada.getApplication().bundle; | |
45 this.items = [{ | |
46 xtype: 'fieldset', | |
47 title: i18n.getMsg('messprogramm.form.fieldset.title'), | |
48 items: [{ | |
49 border: 0, | |
50 margin: '0, 0, 10, 0', | |
51 dockedItems: [{ | |
52 xtype: 'toolbar', | |
53 dock: 'bottom', | |
54 border: '0, 1, 1, 1', | |
55 style: { | |
56 borderBottom: '1px solid #b5b8c8 !important', | |
57 borderLeft: '1px solid #b5b8c8 !important', | |
58 borderRight: '1px solid #b5b8c8 !important' | |
59 }, | |
60 items: ['->', { | |
61 text: i18n.getMsg('save'), | |
62 qtip: i18n.getMsg('save.qtip'), | |
63 icon: 'resources/img/dialog-ok-apply.png', | |
64 action: 'save', | |
65 disabled: true | |
66 }, { | |
67 text: i18n.getMsg('discard'), | |
68 qtip: i18n.getMsg('discard.qtip'), | |
69 icon: 'resources/img/dialog-cancel.png', | |
70 action: 'discard', | |
71 disabled: true | |
72 }] | |
73 }], | |
74 items: [{ | |
75 layout: 'hbox', | |
76 border: 0, | |
77 items: [{ | |
78 border: 0, | |
79 width: '50%', | |
80 minWidth: 290, | |
81 layout: { | |
82 type: 'vbox', | |
83 align: 'stretch' | |
84 }, | |
85 margin: '0, 10, 0, 0', | |
86 items: [{ | |
87 xtype: 'messstelle', | |
88 name: 'mstId', | |
89 fieldLabel: i18n.getMsg('mstId'), | |
90 labelWidth: 135, | |
91 allowBlank: false, | |
92 editable: true | |
93 }, { | |
94 xtype: 'textfield', | |
95 name: 'name', | |
96 fieldLabel: i18n.getMsg('name'), | |
97 labelWidth: 135, | |
98 allowBlank: false, | |
99 editable: true | |
100 }, { | |
101 xtype: 'textarea', //todo: we need a widget which is capable of handling errormsg. | |
102 name: 'probeKommentar', | |
103 labelAlign: 'top', | |
104 fieldLabel: i18n.getMsg('probeKommentar'), | |
105 labelwidth: 135, | |
106 anchor: '100%' | |
107 }] | |
108 }, { | |
109 border: 0, | |
110 width: '50%', | |
111 minWidth: 300, | |
112 margin: '0, 1, 0, 0', | |
113 items: [{ | |
114 xtype: 'fset', | |
115 title: i18n.getMsg('erwAngaben'), | |
116 name: 'erwAngaben', | |
117 collapsible: false, | |
118 collapsed: false, | |
119 items: [{ | |
120 xtype: 'datenbasis', | |
121 editable: false, | |
122 name: 'datenbasisId', | |
123 fieldLabel: i18n.getMsg('datenbasisId'), | |
124 anchor: '100%', | |
125 labelWidth: 105 | |
126 }, { | |
127 xtype: 'betriebsart', | |
128 name: 'baId', | |
129 fieldLabel: i18n.getMsg('baId'), | |
130 anchor: '100%', | |
131 labelWidth: 105 | |
132 }, { | |
133 xtype: 'testdatensatz', | |
134 name: 'test', | |
135 fieldLabel: i18n.getMsg('test'), | |
136 anchor: '100%', | |
137 labelWidth: 105, | |
138 allowBlank: false | |
139 }, { | |
140 xtype: 'probenart', | |
141 editable: false, | |
142 name: 'probenartId', | |
143 fieldLabel: i18n.getMsg('probenartId'), | |
144 anchor: '100%', | |
145 labelWidth: 105, | |
146 allowBlank: false | |
147 }, { | |
148 xtype: 'numberfield', | |
149 allowDecimals: false, | |
150 name: 'probeNehmerId', | |
151 fieldLabel: i18n.getMsg('probeNehmerId'), | |
152 anchor: '100%', | |
153 labelWidth: 105 | |
154 }, { | |
155 xtype: 'netzbetreiber', | |
156 name: 'netzbetreiberId', | |
157 editable: false, | |
158 fieldLabel: i18n.getMsg('netzbetreiberId'), | |
159 anchor: '100%', | |
160 labelWidth: 105, | |
161 allowBlank: false | |
162 }] | |
163 }] | |
164 }] | |
165 }, { | |
166 // Medium | |
167 xtype: 'fieldset', | |
168 title: i18n.getMsg('medium'), | |
169 items: [{ | |
170 border: 0, | |
171 layout: { | |
172 type: 'vbox', | |
173 align: 'stretch' | |
174 }, | |
175 width: '100%', | |
176 items: [{ | |
177 xtype: 'textfield', | |
178 maxLength: 38, | |
179 enforceMaxLength: true, | |
180 name: 'mediaDesk', | |
181 labelWidth: 125, | |
182 fieldLabel: i18n.getMsg('mediaDesk'), | |
183 regex: new RegExp('(?:D: ){1}(?:[0-9]{2} ){11}[0-9]{2}'), | |
184 regexText: i18n.getMsg('err.msg.deskriptorvalidation'), | |
185 listeners: { | |
186 dirtychange: { | |
187 fn: this.updateOnChange, | |
188 scope: me | |
189 } | |
190 } | |
191 }, { | |
192 xtype: 'umwelt', | |
193 name: 'umwId', | |
194 fieldLabel: i18n.getMsg('umwId'), | |
195 labelWidth: 125, | |
196 allowBlank: false, | |
197 editable: true, | |
198 listeners: { | |
199 dirtychange: { | |
200 fn: this.updateOnChange, | |
201 scope: me | |
202 } | |
203 } | |
204 }, { | |
205 xtype: 'fieldset', | |
206 title: i18n.getMsg('deskDetails'), | |
207 collapsible: true, | |
208 collapsed: true, | |
209 defaultType: 'textfield', | |
210 layout: { | |
211 type: 'table', | |
212 columns: 3 | |
213 }, | |
214 items: this.buildDescriptors(), | |
215 listeners: { | |
216 dirtychange: { | |
217 fn: this.updateOnChange, | |
218 scope: me | |
219 } | |
220 } | |
221 }] | |
222 }] | |
223 }, { | |
224 // Zeit | |
225 xtype: 'fieldset', | |
226 title: i18n.getMsg('time'), | |
227 layout: { | |
228 type: 'hbox', | |
229 pack: 'center', | |
230 align: 'stretch' | |
231 }, | |
232 items: [{ | |
233 xtype: 'fset', | |
234 title: i18n.getMsg('validity'), | |
235 name: 'gueltigPeriod', | |
236 anchor: '100%', | |
237 width: '50%', | |
238 margin: '0, 5, 5, 5', | |
239 layout: { | |
240 type: 'vbox', | |
241 align: 'stretch' | |
242 }, | |
243 items: [{ | |
244 xtype: 'datetime', | |
245 fieldLabel: i18n.getMsg('gueltigVon'), | |
246 labelWidth: 90, | |
247 anchor: '100%', | |
248 name: 'gueltigVon', | |
249 format: 'd.m.Y H:i', | |
250 period: 'start' | |
251 }, { | |
252 xtype: 'datetime', | |
253 fieldLabel: i18n.getMsg('gueltigBis'), | |
254 labelWidth: 90, | |
255 anchor: '100%', | |
256 name: 'gueltigBis', | |
257 format: 'd.m.Y H:i', | |
258 period: 'end' | |
259 }] | |
260 }, { | |
261 xtype: 'fset', | |
262 title: i18n.getMsg('probenintervall'), | |
263 name: 'probenintervall', | |
264 anchor: '100%', | |
265 width: '50%', | |
266 margin: '0, 5, 5, 5', | |
267 layout: { | |
268 type: 'vbox', | |
269 align: 'stretch' | |
270 }, | |
271 items: [{ | |
272 xtype: 'probenintervall', | |
273 fieldLabel: i18n.getMsg('probenintervall'), | |
274 labelWidth: 90, | |
275 anchor: '100%', | |
276 name: 'probenintervall' | |
277 }, { | |
278 xtype: 'numberfield', | |
279 fieldLabel: i18n.getMsg('teilintervallVon'), | |
280 labelWidth: 90, | |
281 anchor: '100%', | |
282 name: 'teilintervallVon', | |
283 period: 'start' | |
284 }, { | |
285 xtype: 'numberfield', | |
286 fieldLabel: i18n.getMsg('teilintervallBis'), | |
287 labelWidth: 90, | |
288 anchor: '100%', | |
289 name: 'teilintervallBis', | |
290 period: 'end' | |
291 }, { | |
292 xtype: 'probenintervallslider', | |
293 fieldLabel: i18n.getMsg('intervall'), | |
294 labelWidth: 90, | |
295 anchor: '100%', | |
296 values: [0, 0], | |
297 //this will be overridden | |
298 // by setRecord | |
299 }] | |
300 }] | |
301 }] | |
302 }] | |
303 }]; | |
304 this.callParent(arguments); | |
305 }, | |
306 | |
307 populateIntervall: function(record, intervall) { | |
308 console.log('Populate Start'); | |
309 //intervall is an identifier of a intervall | |
310 // for instance H, M, J, ... | |
311 // Initialize the probenintervallslider | |
312 var s = this.down('probenintervallslider'); | |
313 var v = this.getForm().findField('teilintervallVon'); | |
314 var b = this.getForm().findField('teilintervallBis'); | |
315 var intervallstore = Ext.data.StoreManager.get('Probenintervall'); | |
316 | |
317 var svalUpper = null | |
318 var svalLower = null | |
319 | |
320 if (!intervallstore) { | |
321 intervallstore = Ext.create('Lada.store.Probenintervall'); | |
322 } | |
323 | |
324 //It is likely that this method was not | |
325 // called from the controller, | |
326 //and the probenintervall was not changed. | |
327 // Load the records in this case | |
328 if (!intervall) { | |
329 intervall = record.get('probenintervall', | |
330 0, false, false, true); | |
331 | |
332 svalUpper = record.get('teilintervallBis'); | |
333 svalLower = record.get('teilintervallVon'); | |
334 } | |
335 | |
336 | |
337 var intrec = intervallstore | |
338 .findRecord('probenintervall', | |
339 intervall, 0, false, false, true); | |
340 | |
341 var min = intrec.get('periodstart'); | |
342 var max = intrec.get('periodend'); | |
343 | |
344 if (!svalUpper) { | |
345 svalUpper = max; | |
346 } | |
347 if (!svalLower) { | |
348 svalLower = min; | |
349 } | |
350 | |
351 //Set Teilintervalle | |
352 v.setMinValue(min); | |
353 v.setMaxValue(max); | |
354 b.setMinValue(min); | |
355 b.setMaxValue(max); | |
356 | |
357 //Set Slider | |
358 s.setMinValue(min); | |
359 s.setMaxValue(max); | |
360 | |
361 v.setValue(svalLower); | |
362 b.setValue(svalUpper); | |
363 | |
364 console.log('Populate End'); | |
365 }, | |
366 | |
367 setRecord: function(record) { | |
368 this.clearMessages(); | |
369 this.getForm().loadRecord(record); | |
370 //Set the intervall numberfields and the slider. | |
371 this.down('probenintervallslider').setValue([ | |
372 record.get('teilintervallVon'), | |
373 record.get('teilintervallBis') | |
374 ]); | |
375 | |
376 //TODO Set Sliders MinMaxValue | |
377 | |
378 this.down('probenintervallslider').on( | |
379 'change', | |
380 Lada.app.getController('Lada.controller.form.Messprogramm') | |
381 .synchronizeFields | |
382 ); | |
383 | |
384 }, | |
385 | |
386 setMessages: function(errors, warnings) { | |
387 var key; | |
388 var element; | |
389 var content; | |
390 var i18n = Lada.getApplication().bundle; | |
391 if (warnings) { | |
392 for (key in warnings) { | |
393 element = this.down('component[name=' + key + ']'); | |
394 if (!element) { | |
395 continue; | |
396 } | |
397 content = warnings[key]; | |
398 var warnText = ''; | |
399 for (var i = 0; i < content.length; i++) { | |
400 warnText += i18n.getMsg(content[i].toString()) + '\n'; | |
401 } | |
402 element.showWarnings(warnText); | |
403 } | |
404 } | |
405 if (errors) { | |
406 for (key in errors) { | |
407 element = this.down('component[name=' + key + ']'); | |
408 if (!element) { | |
409 continue; | |
410 } | |
411 content = errors[key]; | |
412 var errorText = ''; | |
413 for (var i = 0; i < content.length; i++) { | |
414 errorText += i18n.getMsg(content[i].toString()) + '\n'; | |
415 } | |
416 element.showErrors(errorText); | |
417 } | |
418 } | |
419 }, | |
420 | |
421 clearMessages: function() { | |
422 // TODO | |
423 }, | |
424 | |
425 setReadOnly: function(value) { | |
426 // TODO | |
427 }, | |
428 | |
429 buildDescriptors: function() { | |
430 var fields = []; | |
431 for (var i = 0; i < 12; i++) { | |
432 fields[i] = { | |
433 fieldLabel: 'S' + i, | |
434 name: 's' + i, | |
435 labelWidth: 25, | |
436 margin: '0, 10, 5, 0' | |
437 }; | |
438 } | |
439 return fields; | |
440 } | |
441 }); |