Mercurial > lada > lada-client
comparison app/view/form/Ortserstellung.js @ 1295:171eacf989d8
Show error and warnings in new forms
author | Maximilian Krambach <mkrambach@intevation.de> |
---|---|
date | Thu, 02 Feb 2017 11:04:01 +0100 |
parents | c1b7db04b39c |
children | 5dfd5798cbcc |
comparison
equal
deleted
inserted
replaced
1294:c1b7db04b39c | 1295:171eacf989d8 |
---|---|
269 this_panel.record.set('netzbetreiberId', Lada.netzbetreiber[0]); | 269 this_panel.record.set('netzbetreiberId', Lada.netzbetreiber[0]); |
270 this_panel.record.save({ | 270 this_panel.record.save({ |
271 success: function(record, response) { | 271 success: function(record, response) { |
272 var newOrtId; | 272 var newOrtId; |
273 var ozw = this_panel.up().parentWindow; | 273 var ozw = this_panel.up().parentWindow; |
274 var json = Ext.decode(response.response.responseText); | |
275 if (json) { | |
276 this_panel.clearMessages(); | |
277 this_panel.setMessages(json.errors, json.warnings); | |
278 } | |
274 ozw.ortstore.load({ | 279 ozw.ortstore.load({ |
275 callback: function(records, operation, success) { | 280 callback: function(records, operation, success) { |
276 ozw.down('map').addLocations(ozw.ortstore); | 281 ozw.down('map').addLocations(ozw.ortstore); |
277 var osg = ozw.down('ortstammdatengrid'); | 282 var osg = ozw.down('ortstammdatengrid'); |
278 osg.setStore(ozw.ortstore); | 283 osg.setStore(ozw.ortstore); |
284 title: Lada.getApplication().bundle.getMsg('success'), | 289 title: Lada.getApplication().bundle.getMsg('success'), |
285 autoScroll: true, | 290 autoScroll: true, |
286 msg: 'Ort erfolgreich angelegt!', | 291 msg: 'Ort erfolgreich angelegt!', |
287 buttons: Ext.Msg.OK | 292 buttons: Ext.Msg.OK |
288 }); | 293 }); |
289 this_panel.close(); | |
290 }, | 294 }, |
291 scope: this | 295 scope: this |
292 }); | 296 }); |
293 | 297 |
294 }, | 298 }, |
310 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'), | 314 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'), |
311 Lada.getApplication().bundle.getMsg('err.msg.response.body')); | 315 Lada.getApplication().bundle.getMsg('err.msg.response.body')); |
312 } | 316 } |
313 } | 317 } |
314 }); | 318 }); |
315 } | 319 }, |
320 | |
321 setMessages: function(errors, warnings) { | |
322 var key; | |
323 var element; | |
324 var content; | |
325 var i18n = Lada.getApplication().bundle; | |
326 if (warnings) { | |
327 for (key in warnings) { | |
328 element = this.down('component[name=' + key + ']'); | |
329 if (!element) { | |
330 continue; | |
331 } | |
332 content = warnings[key]; | |
333 var warnText = ''; | |
334 for (var i = 0; i < content.length; i++) { | |
335 warnText += i18n.getMsg(content[i].toString()) + '\n'; | |
336 } | |
337 element.showWarnings(warnText); | |
338 } | |
339 } | |
340 if (errors) { | |
341 for (key in errors) { | |
342 element = this.down('component[name=' + key + ']'); | |
343 if (!element) { | |
344 continue; | |
345 } | |
346 content = errors[key]; | |
347 var errorText = ''; | |
348 for (var i = 0; i < content.length; i++) { | |
349 errorText += i18n.getMsg(content[i].toString()) + '\n'; | |
350 } | |
351 element.showErrors(errorText); | |
352 } | |
353 } | |
354 }, | |
355 | |
356 clearMessages: function() { | |
357 // TODO: this is a stub | |
358 } | |
359 | |
316 }); | 360 }); |