Mercurial > lada > lada-client
comparison app/controller/grid/ProbeList.js @ 1265:a4c1a9862a88
merged
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 14 Dec 2016 10:21:48 +0100 |
parents | 52ecf67e9e80 |
children | c4059495a346 |
comparison
equal
deleted
inserted
replaced
1264:3d83bcb02ee3 | 1265:a4c1a9862a88 |
---|---|
157 case "printsheet" : | 157 case "printsheet" : |
158 // The Data is loaded from the server again, so we need | 158 // The Data is loaded from the server again, so we need |
159 // to be a little bit asynchronous here... | 159 // to be a little bit asynchronous here... |
160 callback = function(response) { | 160 callback = function(response) { |
161 var data = response.responseText; | 161 var data = response.responseText; |
162 data = this.prepareData(data); // Wraps all messstellen and deskriptoren objects into an array | |
162 var printData = '{"layout": "A4 portrait", "outputFormat": "pdf",' | 163 var printData = '{"layout": "A4 portrait", "outputFormat": "pdf",' |
163 + '"attributes": { "proben": ' + data | 164 + '"attributes": { "proben": ' + data |
164 + '}}'; | 165 + '}}'; |
165 this.printpdf(printData, 'lada_erfassungsbogen', | 166 this.printpdf(printData, 'lada_erfassungsbogen', |
166 'lada-erfassungsbogen.pdf', button); | 167 'lada-erfassungsbogen.pdf', button); |
167 } | 168 } |
168 | 169 |
169 this.createSheetData(button, callback, this); | 170 this.createSheetData(button, callback, this); |
170 break; | 171 break; |
171 } | 172 } |
173 }, | |
174 | |
175 prepareData: function(data) { | |
176 // Copy data | |
177 prep = JSON.parse(data); | |
178 data = JSON.parse(data); | |
179 // ensure data and prep are equal, not sure | |
180 // if json.parse changes order of things | |
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 | |
207 for (i in data) { | |
208 probe = data[i]; | |
209 deskriptoren = probe.deskriptoren; | |
210 messstelle = probe.messstelle; | |
211 if (messstelle != null) { | |
212 prep[i].messstelle = []; | |
213 prep[i].messstelle[0] = messstelle; | |
214 } | |
215 else { | |
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 } | |
228 } | |
229 return JSON.stringify(prep); | |
172 }, | 230 }, |
173 | 231 |
174 /** | 232 /** |
175 * Toggles the buttons in the toolbar | 233 * Toggles the buttons in the toolbar |
176 **/ | 234 **/ |
227 // var element = Ext.get('probe-row-' + record.get('id')).down('div'); | 285 // var element = Ext.get('probe-row-' + record.get('id')).down('div'); |
228 // element.destroy(); | 286 // element.destroy(); |
229 }, | 287 }, |
230 | 288 |
231 /** | 289 /** |
232 * Returns a Json-Object whcih contains the data which has | 290 * Returns a Json-Object which contains the data which has |
233 * to be printed. | 291 * to be printed. |
234 * The parameter printFunctionCallback will be called once the ajax-request | 292 * The parameter printFunctionCallback will be called once the ajax-request |
235 * starting the json-export was evaluated | 293 * starting the json-export was evaluated |
236 **/ | 294 **/ |
237 createSheetData: function(button, printFunctionCallback, cbscope){ | 295 createSheetData: function(button, printFunctionCallback, cbscope){ |
238 //disable Button and setLoading... | 296 //disable Button and setLoading... |
239 // TODO ACTIVATE! | 297 button.disable(); |
240 //button.disable(); | 298 button.setLoading(true); |
241 //button.setLoading(true); | |
242 | 299 |
243 | 300 |
244 // get Selected Items. | 301 // get Selected Items. |
245 var grid = button.up('grid'); | 302 var grid = button.up('grid'); |
246 var selection = grid.getView().getSelectionModel().getSelection(); | 303 var selection = grid.getView().getSelectionModel().getSelection(); |
267 // Error handling | 324 // Error handling |
268 // TODO | 325 // TODO |
269 console.log(response.responseText) | 326 console.log(response.responseText) |
270 button.enable(); | 327 button.enable(); |
271 button.setLoading(false); | 328 button.setLoading(false); |
272 // This is "copy & waste-code" from downloadFile | 329 if (response.responseText) { |
273 // FIXME | 330 try { |
274 /* | 331 var json = Ext.JSON.decode(response.responseText); |
275 SSO will send a 302 if the Client is not authenticated | 332 } |
276 unfortunately this seems to be filtered by the browser. | 333 catch(e){ |
277 We assume that a 302 was send when the follwing statement | 334 console.log(e); |
278 is true. | 335 } |
279 */ | 336 } |
280 if (response.status == 0 && response.responseText === "") { | |
281 Ext.MessageBox.confirm(Lada.getApplication().bundle.getMsg('err.msg.sso.expired.title'), | |
282 Lada.getApplication().bundle.getMsg('err.msg.sso.expired.body'), | |
283 this.reload); | |
284 } | |
285 // further error handling | |
286 var json = Ext.JSON.decode(response.responseText); | |
287 if (json) { | 337 if (json) { |
288 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){ | 338 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){ |
289 formPanel.setMessages(json.errors, json.warnings); | 339 formPanel.setMessages(json.errors, json.warnings); |
290 } | 340 } |
291 if(json.message){ | 341 if(json.message){ |
292 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title') | 342 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title') |
293 +' #'+json.message, | 343 +' #'+json.message, |
294 Lada.getApplication().bundle.getMsg(json.message)); | 344 Lada.getApplication().bundle.getMsg(json.message)); |
295 } else { | 345 } else { |
296 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), | 346 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), |
297 i18n.getMsg('err.msg.print.failed')); | 347 i18n.getMsg('err.msg.response.body')); |
298 } | 348 } |
299 } else { | 349 } else { |
300 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), | 350 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), |
301 i18n.getMsg('err.msg.print.failed')); | 351 i18n.getMsg('err.msg.response.body')); |
302 } | 352 } |
303 | |
304 return null; | 353 return null; |
305 } | 354 } |
306 }); | 355 }); |
307 }, | 356 }, |
308 | 357 |
309 /** | 358 /** |
310 * Returns a Json-Object whcih contains the data which has | 359 * Returns a Json-Object which contains the data which has |
311 * to be printed. | 360 * to be printed. |
312 **/ | 361 **/ |
313 createExtractData: function(button){ | 362 createExtractData: function(button){ |
314 //disable Button and setLoading... | 363 //disable Button and setLoading... |
315 button.disable(); | 364 button.disable(); |