Mercurial > lada > lada-client
changeset 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 | 26197c2d9362 |
files | app/controller/grid/ProbeList.js |
diffstat | 1 files changed, 55 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/app/controller/grid/ProbeList.js Thu Dec 01 14:55:31 2016 +0100 +++ b/app/controller/grid/ProbeList.js Tue Dec 06 14:03:57 2016 +0100 @@ -179,17 +179,52 @@ // ensure data and prep are equal, not sure // if json.parse changes order of things console.log(data); + + emptyMessstelle = { + "id": null, + "amtskennung": null, + "beschreibung": null, + "messStelle": null, + "mstTyp": null, + "netzbetreiberId":null + }; + + emptyDeskriptor = { + "s0": null, + "s1": null, + "s2": null, + "s3": null, + "s4": null, + "s5": null, + "s6": null, + "s7": null, + "s8": null, + "s9": null, + "s10": null, + "s11": null + }; + for (i in data) { probe = data[i]; - console.log(probe); deskriptoren = probe.deskriptoren; messstelle = probe.messstelle; - console.log(deskriptoren); - console.log(messstelle); - prep[i].messstelle = []; - prep[i].messstelle[0] = messstelle; - prep[i].deskriptoren = []; - prep[i].deskriptoren[0] = deskriptoren; + if (messstelle != null) { + prep[i].messstelle = []; + prep[i].messstelle[0] = messstelle; + } + else { + prep[i].messstelle = []; + prep[i].messstelle[0] = emptyMessstelle; + } + + if (deskriptoren != null) { + prep[i].deskriptoren = []; + prep[i].deskriptoren[0] = deskriptoren; + } + else { + prep[i].deskriptoren = []; + prep[i].deskriptoren[0] = emptyDeskriptor; + } } return JSON.stringify(prep); }, @@ -252,16 +287,15 @@ }, /** - * Returns a Json-Object whcih contains the data which has + * Returns a Json-Object which contains the data which has * to be printed. * The parameter printFunctionCallback will be called once the ajax-request * starting the json-export was evaluated **/ createSheetData: function(button, printFunctionCallback, cbscope){ //disable Button and setLoading... - // TODO ACTIVATE! - //button.disable(); - //button.setLoading(true); + button.disable(); + button.setLoading(true); // get Selected Items. @@ -292,21 +326,14 @@ console.log(response.responseText) button.enable(); button.setLoading(false); - // This is "copy & waste-code" from downloadFile - // FIXME - /* - SSO will send a 302 if the Client is not authenticated - unfortunately this seems to be filtered by the browser. - We assume that a 302 was send when the follwing statement - is true. - */ - if (response.status == 0 && response.responseText === "") { - Ext.MessageBox.confirm(Lada.getApplication().bundle.getMsg('err.msg.sso.expired.title'), - Lada.getApplication().bundle.getMsg('err.msg.sso.expired.body'), - this.reload); + if (response.responseText) { + try { + var json = Ext.JSON.decode(response.responseText); + } + catch(e){ + console.log(e); + } } - // further error handling - var json = Ext.JSON.decode(response.responseText); if (json) { if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){ formPanel.setMessages(json.errors, json.warnings); @@ -317,20 +344,19 @@ Lada.getApplication().bundle.getMsg(json.message)); } else { Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), - i18n.getMsg('err.msg.print.failed')); + i18n.getMsg('err.msg.response.body')); } } else { Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), - i18n.getMsg('err.msg.print.failed')); + i18n.getMsg('err.msg.response.body')); } - return null; } }); }, /** - * Returns a Json-Object whcih contains the data which has + * Returns a Json-Object which contains the data which has * to be printed. **/ createExtractData: function(button){