Mercurial > lada > lada-client
comparison app/view/window/GenProbenFromMessprogramm.js @ 1204:95d24315d68e
Improve readability.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Fri, 30 Sep 2016 10:36:47 +0200 |
parents | 39d98891881c |
children | 613e48a3fef9 |
comparison
equal
deleted
inserted
replaced
1203:684eccd8dac0 | 1204:95d24315d68e |
---|---|
66 | 66 |
67 Ext.Ajax.request({ | 67 Ext.Ajax.request({ |
68 url: 'lada-server/rest/probe/messprogramm', | 68 url: 'lada-server/rest/probe/messprogramm', |
69 method: 'POST', | 69 method: 'POST', |
70 jsonData: jsondata, | 70 jsonData: jsondata, |
71 success: function(response) { | 71 success: me.onSuccess, |
72 var json = Ext.JSON.decode(response.responseText); | 72 failure: me.onFailure, |
73 var radio = Ext.ComponentQuery.query('modeswitcher')[0].down('radiofield[inputValue=proben]'); | |
74 radio.setValue(true); | |
75 | |
76 var contentPanel = Ext.ComponentQuery.query('panel[name=main]')[0].down('panel[name=contentpanel]'); | |
77 contentPanel.removeAll(); //clear the panel: make space for new grids | |
78 var gridstore = Ext.create('Lada.store.Proben'); | |
79 var frgrid = Ext.create('Lada.view.grid.ProbeList', { | |
80 plugins: [{ | |
81 ptype: 'gridrowexpander', | |
82 gridType: 'Lada.view.grid.Messung', | |
83 expandOnDblClick: false, | |
84 gridConfig: { | |
85 bottomBar: false | |
86 } | |
87 }] | |
88 }); | |
89 | |
90 var columns = [{ | |
91 header: i18n.getMsg('prnId'), | |
92 dataIndex: 'probeIdAlt' | |
93 }, { | |
94 header: i18n.getMsg('netzbetreiberId'), | |
95 dataIndex: 'netzbetreiberId', | |
96 renderer: function(value) { | |
97 var r = ''; | |
98 if (!value || value === '') { | |
99 r = 'Error'; | |
100 } | |
101 var store = Ext.data.StoreManager.get('netzbetreiber'); | |
102 var record = store.getById(value); | |
103 if (record) { | |
104 r = record.get('netzbetreiber'); | |
105 } | |
106 return r; | |
107 } | |
108 }, { | |
109 header: i18n.getMsg('mstId'), | |
110 dataIndex: 'mstId', | |
111 renderer: function(value) { | |
112 var r = ''; | |
113 if (!value || value === '') { | |
114 r = 'Error'; | |
115 } | |
116 var store = Ext.data.StoreManager.get('messstellen'); | |
117 var record = store.getById(value); | |
118 if (record) { | |
119 r = record.get('messStelle'); | |
120 } | |
121 return r; | |
122 } | |
123 }, { | |
124 header: i18n.getMsg('datenbasisId'), | |
125 dataIndex: 'datenbasisId', | |
126 renderer: function(value) { | |
127 var r = ''; | |
128 if (!value || value === '') { | |
129 r = value; | |
130 } | |
131 var store = Ext.data.StoreManager.get('datenbasis'); | |
132 var record = store.getById(value); | |
133 if (record) { | |
134 r = record.get('datenbasis'); | |
135 } | |
136 return r; | |
137 } | |
138 }, { | |
139 header: i18n.getMsg('baId'), | |
140 dataIndex: 'baId', | |
141 renderer: function(value) { | |
142 var r = ''; | |
143 if (!value || value === '') { | |
144 r = ''; | |
145 } | |
146 var store = Ext.create('Ext.data.Store', { | |
147 fields: ['betriebsartId', 'betriebsart'], | |
148 data: [{ | |
149 'betriebsartId': '1', | |
150 'betriebsart': 'Normal-/Routinebetrieb' | |
151 }, { | |
152 'betriebsartId': '2', | |
153 'betriebsart': 'Störfall/Intensivbetrieb' | |
154 }] | |
155 }); | |
156 var record = store.getById(value); | |
157 if (record) { | |
158 r = record.get('betriebsart'); | |
159 } | |
160 return r; | |
161 } | |
162 }, { | |
163 header: i18n.getMsg('probenartId'), | |
164 dataIndex: 'probenartId', | |
165 renderer: function(value) { | |
166 var r = ''; | |
167 if (!value || value === '') { | |
168 r = value; | |
169 } | |
170 var store = Ext.data.StoreManager.get('probenarten'); | |
171 var record = store.getById(value); | |
172 if (record) { | |
173 r = record.get('probenart'); | |
174 } | |
175 return r; | |
176 } | |
177 }, { | |
178 header: i18n.getMsg('sollVon'), | |
179 dataIndex: 'solldatumBeginn', | |
180 renderer: function(value) { | |
181 console.log(value); | |
182 if (!value) { | |
183 return ''; | |
184 } | |
185 return Ext.Date.format(value, 'd.m.Y'); | |
186 } | |
187 }, { | |
188 header: i18n.getMsg('sollBis'), | |
189 dataIndex: 'solldatumEnde', | |
190 renderer: function(value) { | |
191 if (!value) { | |
192 return ''; | |
193 } | |
194 return Ext.Date.format(value, 'd.m.Y'); | |
195 } | |
196 }]; | |
197 frgrid.reconfigure(gridstore, columns); | |
198 | |
199 gridstore.loadData(json.data); | |
200 contentPanel.add(frgrid); | |
201 Ext.Msg.show({ | |
202 title: i18n.getMsg('success'), | |
203 autoScroll: true, | |
204 msg: me.evalResponse(json), | |
205 buttons: Ext.Msg.OK | |
206 }); | |
207 me.close(); | |
208 }, | |
209 failure: function(response) { | |
210 var json = null; | |
211 try { | |
212 json = Ext.JSON.decode(response.responseText); | |
213 } | |
214 catch(err){ | |
215 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title'), | |
216 Lada.getApplication().bundle.getMsg('err.msg.response.body')); | |
217 } | |
218 if (json) { | |
219 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){ | |
220 formPanel.setMessages(json.errors, json.warnings); | |
221 } | |
222 /* | |
223 SSO will send a 302 if the Client is not authenticated | |
224 unfortunately this seems to be filtered by the browser. | |
225 We assume that a 302 was send when the follwing statement | |
226 is true. | |
227 */ | |
228 if (response.status == 0 && response.responseText === "") { | |
229 Ext.MessageBox.confirm('Erneutes Login erforderlich', | |
230 'Ihre Session ist abgelaufen.<br/>'+ | |
231 'Für ein erneutes Login muss die Anwendung neu geladen werden.<br/>' + | |
232 'Alle ungesicherten Daten gehen dabei verloren.<br/>' + | |
233 'Soll die Anwendung jetzt neu geladen werden?', this.reload); | |
234 } | |
235 // further error handling | |
236 if(json.message){ | |
237 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title') | |
238 +' #'+json.message, | |
239 Lada.getApplication().bundle.getMsg(json.message)); | |
240 } else { | |
241 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title'), | |
242 Lada.getApplication().bundle.getMsg('err.msg.generic.body')); | |
243 } | |
244 } else { | |
245 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title'), | |
246 Lada.getApplication().bundle.getMsg('err.msg.response.body')); | |
247 } | |
248 } | |
249 }); | 73 }); |
250 } | 74 } |
251 }]; | 75 }]; |
252 this.width = 350; | 76 this.width = 350; |
253 this.height = 250; | 77 this.height = 250; |
311 }]; | 135 }]; |
312 this.callParent(arguments); | 136 this.callParent(arguments); |
313 }, | 137 }, |
314 | 138 |
315 /** | 139 /** |
140 * Callback on success of request (HTTP status 200) | |
141 */ | |
142 onSuccess: function(response) { | |
143 var i18n = Lada.getApplication().bundle; | |
144 | |
145 var json = Ext.JSON.decode(response.responseText); | |
146 var radio = Ext.ComponentQuery.query('modeswitcher')[0] | |
147 .down('radiofield[inputValue=proben]'); | |
148 radio.setValue(true); | |
149 | |
150 var contentPanel = Ext.ComponentQuery.query('panel[name=main]')[0] | |
151 .down('panel[name=contentpanel]'); | |
152 contentPanel.removeAll(); //clear the panel: make space for new grids | |
153 var gridstore = Ext.create('Lada.store.Proben'); | |
154 var frgrid = Ext.create('Lada.view.grid.ProbeList', { | |
155 plugins: [{ | |
156 ptype: 'gridrowexpander', | |
157 gridType: 'Lada.view.grid.Messung', | |
158 expandOnDblClick: false, | |
159 gridConfig: { | |
160 bottomBar: false | |
161 } | |
162 }] | |
163 }); | |
164 | |
165 var columns = [{ | |
166 header: i18n.getMsg('prnId'), | |
167 dataIndex: 'probeIdAlt' | |
168 }, { | |
169 header: i18n.getMsg('netzbetreiberId'), | |
170 dataIndex: 'netzbetreiberId', | |
171 renderer: function(value) { | |
172 var r = ''; | |
173 if (!value || value === '') { | |
174 r = 'Error'; | |
175 } | |
176 var store = Ext.data.StoreManager.get('netzbetreiber'); | |
177 var record = store.getById(value); | |
178 if (record) { | |
179 r = record.get('netzbetreiber'); | |
180 } | |
181 return r; | |
182 } | |
183 }, { | |
184 header: i18n.getMsg('mstId'), | |
185 dataIndex: 'mstId', | |
186 renderer: function(value) { | |
187 var r = ''; | |
188 if (!value || value === '') { | |
189 r = 'Error'; | |
190 } | |
191 var store = Ext.data.StoreManager.get('messstellen'); | |
192 var record = store.getById(value); | |
193 if (record) { | |
194 r = record.get('messStelle'); | |
195 } | |
196 return r; | |
197 } | |
198 }, { | |
199 header: i18n.getMsg('datenbasisId'), | |
200 dataIndex: 'datenbasisId', | |
201 renderer: function(value) { | |
202 var r = ''; | |
203 if (!value || value === '') { | |
204 r = value; | |
205 } | |
206 var store = Ext.data.StoreManager.get('datenbasis'); | |
207 var record = store.getById(value); | |
208 if (record) { | |
209 r = record.get('datenbasis'); | |
210 } | |
211 return r; | |
212 } | |
213 }, { | |
214 header: i18n.getMsg('baId'), | |
215 dataIndex: 'baId', | |
216 renderer: function(value) { | |
217 var r = ''; | |
218 if (!value || value === '') { | |
219 r = ''; | |
220 } | |
221 var store = Ext.create('Ext.data.Store', { | |
222 fields: ['betriebsartId', 'betriebsart'], | |
223 data: [{ | |
224 'betriebsartId': '1', | |
225 'betriebsart': 'Normal-/Routinebetrieb' | |
226 }, { | |
227 'betriebsartId': '2', | |
228 'betriebsart': 'Störfall/Intensivbetrieb' | |
229 }] | |
230 }); | |
231 var record = store.getById(value); | |
232 if (record) { | |
233 r = record.get('betriebsart'); | |
234 } | |
235 return r; | |
236 } | |
237 }, { | |
238 header: i18n.getMsg('probenartId'), | |
239 dataIndex: 'probenartId', | |
240 renderer: function(value) { | |
241 var r = ''; | |
242 if (!value || value === '') { | |
243 r = value; | |
244 } | |
245 var store = Ext.data.StoreManager.get('probenarten'); | |
246 var record = store.getById(value); | |
247 if (record) { | |
248 r = record.get('probenart'); | |
249 } | |
250 return r; | |
251 } | |
252 }, { | |
253 header: i18n.getMsg('sollVon'), | |
254 dataIndex: 'solldatumBeginn', | |
255 renderer: function(value) { | |
256 if (!value) { | |
257 return ''; | |
258 } | |
259 return Ext.Date.format(value, 'd.m.Y'); | |
260 } | |
261 }, { | |
262 header: i18n.getMsg('sollBis'), | |
263 dataIndex: 'solldatumEnde', | |
264 renderer: function(value) { | |
265 if (!value) { | |
266 return ''; | |
267 } | |
268 return Ext.Date.format(value, 'd.m.Y'); | |
269 } | |
270 }]; | |
271 frgrid.reconfigure(gridstore, columns); | |
272 | |
273 gridstore.loadData(json.data); | |
274 contentPanel.add(frgrid); | |
275 Ext.Msg.show({ | |
276 title: i18n.getMsg('success'), | |
277 autoScroll: true, | |
278 msg: me.evalResponse(json), | |
279 buttons: Ext.Msg.OK | |
280 }); | |
281 me.close(); | |
282 }, | |
283 | |
284 /** | |
285 * Callback on failure of request (HTTP status != 200) | |
286 */ | |
287 onFailure: function(response) { | |
288 var i18n = Lada.getApplication().bundle; | |
289 | |
290 var json = null; | |
291 try { | |
292 json = Ext.JSON.decode(response.responseText); | |
293 } | |
294 catch(err){ | |
295 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), | |
296 i18n.getMsg('err.msg.response.body')); | |
297 } | |
298 if (json) { | |
299 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){ | |
300 formPanel.setMessages(json.errors, json.warnings); | |
301 } | |
302 /* | |
303 SSO will send a 302 if the Client is not authenticated | |
304 unfortunately this seems to be filtered by the browser. | |
305 We assume that a 302 was send when the follwing statement | |
306 is true. | |
307 */ | |
308 if (response.status == 0 && response.responseText === "") { | |
309 Ext.MessageBox.confirm( | |
310 'Erneutes Login erforderlich', | |
311 'Ihre Session ist abgelaufen.<br/>' | |
312 + 'Für ein erneutes Login muss die Anwendung ' | |
313 + 'neu geladen werden.<br/>' | |
314 + 'Alle ungesicherten Daten gehen dabei verloren.<br/>' | |
315 + 'Soll die Anwendung jetzt neu geladen werden?', | |
316 this.reload); | |
317 } | |
318 // further error handling | |
319 if(json.message){ | |
320 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title') | |
321 +' #'+json.message, | |
322 i18n.getMsg(json.message)); | |
323 } else { | |
324 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), | |
325 i18n.getMsg('err.msg.generic.body')); | |
326 } | |
327 } else { | |
328 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), | |
329 i18n.getMsg('err.msg.response.body')); | |
330 } | |
331 }, | |
332 | |
333 | |
334 /** | |
316 * Initiatlise the Data | 335 * Initiatlise the Data |
317 */ | 336 */ |
318 initData: function() { | 337 initData: function() { |
319 var i18n = Lada.getApplication().bundle; | 338 var i18n = Lada.getApplication().bundle; |
320 me = this; | 339 me = this; |