comparison app/controller/grid/ProbeList.js @ 1262:52ecf67e9e80

Fixes an Issue when the Probe which has to be printed does not contain deskriptoren
author Dustin Demuth <dustin@intevation.de>
date Tue, 06 Dec 2016 14:03:57 +0100
parents d19170280a23
children c4059495a346
comparison
equal deleted inserted replaced
1261:d19170280a23 1262:52ecf67e9e80
177 prep = JSON.parse(data); 177 prep = JSON.parse(data);
178 data = JSON.parse(data); 178 data = JSON.parse(data);
179 // ensure data and prep are equal, not sure 179 // ensure data and prep are equal, not sure
180 // if json.parse changes order of things 180 // if json.parse changes order of things
181 console.log(data); 181 console.log(data);
182
183 emptyMessstelle = {
184 "id": null,
185 "amtskennung": null,
186 "beschreibung": null,
187 "messStelle": null,
188 "mstTyp": null,
189 "netzbetreiberId":null
190 };
191
192 emptyDeskriptor = {
193 "s0": null,
194 "s1": null,
195 "s2": null,
196 "s3": null,
197 "s4": null,
198 "s5": null,
199 "s6": null,
200 "s7": null,
201 "s8": null,
202 "s9": null,
203 "s10": null,
204 "s11": null
205 };
206
182 for (i in data) { 207 for (i in data) {
183 probe = data[i]; 208 probe = data[i];
184 console.log(probe);
185 deskriptoren = probe.deskriptoren; 209 deskriptoren = probe.deskriptoren;
186 messstelle = probe.messstelle; 210 messstelle = probe.messstelle;
187 console.log(deskriptoren); 211 if (messstelle != null) {
188 console.log(messstelle); 212 prep[i].messstelle = [];
189 prep[i].messstelle = []; 213 prep[i].messstelle[0] = messstelle;
190 prep[i].messstelle[0] = messstelle; 214 }
191 prep[i].deskriptoren = []; 215 else {
192 prep[i].deskriptoren[0] = deskriptoren; 216 prep[i].messstelle = [];
217 prep[i].messstelle[0] = emptyMessstelle;
218 }
219
220 if (deskriptoren != null) {
221 prep[i].deskriptoren = [];
222 prep[i].deskriptoren[0] = deskriptoren;
223 }
224 else {
225 prep[i].deskriptoren = [];
226 prep[i].deskriptoren[0] = emptyDeskriptor;
227 }
193 } 228 }
194 return JSON.stringify(prep); 229 return JSON.stringify(prep);
195 }, 230 },
196 231
197 /** 232 /**
250 // var element = Ext.get('probe-row-' + record.get('id')).down('div'); 285 // var element = Ext.get('probe-row-' + record.get('id')).down('div');
251 // element.destroy(); 286 // element.destroy();
252 }, 287 },
253 288
254 /** 289 /**
255 * Returns a Json-Object whcih contains the data which has 290 * Returns a Json-Object which contains the data which has
256 * to be printed. 291 * to be printed.
257 * The parameter printFunctionCallback will be called once the ajax-request 292 * The parameter printFunctionCallback will be called once the ajax-request
258 * starting the json-export was evaluated 293 * starting the json-export was evaluated
259 **/ 294 **/
260 createSheetData: function(button, printFunctionCallback, cbscope){ 295 createSheetData: function(button, printFunctionCallback, cbscope){
261 //disable Button and setLoading... 296 //disable Button and setLoading...
262 // TODO ACTIVATE! 297 button.disable();
263 //button.disable(); 298 button.setLoading(true);
264 //button.setLoading(true);
265 299
266 300
267 // get Selected Items. 301 // get Selected Items.
268 var grid = button.up('grid'); 302 var grid = button.up('grid');
269 var selection = grid.getView().getSelectionModel().getSelection(); 303 var selection = grid.getView().getSelectionModel().getSelection();
290 // Error handling 324 // Error handling
291 // TODO 325 // TODO
292 console.log(response.responseText) 326 console.log(response.responseText)
293 button.enable(); 327 button.enable();
294 button.setLoading(false); 328 button.setLoading(false);
295 // This is "copy & waste-code" from downloadFile 329 if (response.responseText) {
296 // FIXME 330 try {
297 /* 331 var json = Ext.JSON.decode(response.responseText);
298 SSO will send a 302 if the Client is not authenticated 332 }
299 unfortunately this seems to be filtered by the browser. 333 catch(e){
300 We assume that a 302 was send when the follwing statement 334 console.log(e);
301 is true. 335 }
302 */ 336 }
303 if (response.status == 0 && response.responseText === "") {
304 Ext.MessageBox.confirm(Lada.getApplication().bundle.getMsg('err.msg.sso.expired.title'),
305 Lada.getApplication().bundle.getMsg('err.msg.sso.expired.body'),
306 this.reload);
307 }
308 // further error handling
309 var json = Ext.JSON.decode(response.responseText);
310 if (json) { 337 if (json) {
311 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){ 338 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){
312 formPanel.setMessages(json.errors, json.warnings); 339 formPanel.setMessages(json.errors, json.warnings);
313 } 340 }
314 if(json.message){ 341 if(json.message){
315 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title') 342 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title')
316 +' #'+json.message, 343 +' #'+json.message,
317 Lada.getApplication().bundle.getMsg(json.message)); 344 Lada.getApplication().bundle.getMsg(json.message));
318 } else { 345 } else {
319 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), 346 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
320 i18n.getMsg('err.msg.print.failed')); 347 i18n.getMsg('err.msg.response.body'));
321 } 348 }
322 } else { 349 } else {
323 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), 350 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
324 i18n.getMsg('err.msg.print.failed')); 351 i18n.getMsg('err.msg.response.body'));
325 } 352 }
326
327 return null; 353 return null;
328 } 354 }
329 }); 355 });
330 }, 356 },
331 357
332 /** 358 /**
333 * Returns a Json-Object whcih contains the data which has 359 * Returns a Json-Object which contains the data which has
334 * to be printed. 360 * to be printed.
335 **/ 361 **/
336 createExtractData: function(button){ 362 createExtractData: function(button){
337 //disable Button and setLoading... 363 //disable Button and setLoading...
338 button.disable(); 364 button.disable();

http://lada.wald.intevation.org