Mercurial > lada > lada-client
comparison app/view/form/Ortserstellung.js @ 1319:518b4c28e71a
Ortserstellung does no longer update existing Orte
author | Maximilian Krambach <mkrambach@intevation.de> |
---|---|
date | Fri, 03 Feb 2017 14:25:38 +0100 |
parents | 8ace34d9352a |
children | 754db8d73691 |
comparison
equal
deleted
inserted
replaced
1318:cc90b8050887 | 1319:518b4c28e71a |
---|---|
270 } | 270 } |
271 }, | 271 }, |
272 | 272 |
273 saveOrt: function() { | 273 saveOrt: function() { |
274 var this_panel = this.up('panel'); | 274 var this_panel = this.up('panel'); |
275 var me = this; | |
275 var form = this_panel.getForm(); | 276 var form = this_panel.getForm(); |
276 var record = form.getRecord(); | 277 var record = form.getRecord(); |
277 var oldId = record.get('ortId'); | |
278 var data = form.getFieldValues(true); | 278 var data = form.getFieldValues(true); |
279 for (var key in data) { | 279 for (var key in data) { |
280 record.set(key, data[key]); | 280 record.set(key, data[key]); |
281 } | 281 } |
282 record.set('id', null); | |
282 record.set('netzbetreiberId', Lada.netzbetreiber[0]); | 283 record.set('netzbetreiberId', Lada.netzbetreiber[0]); |
283 record.save({ | 284 record.save({ |
284 success: function(newrecord, response) { | 285 success: function(newrecord, response) { |
285 form.loadRecord(newrecord); | 286 form.loadRecord(newrecord); |
287 this_panel.down('verwaltungseinheit').store.load( | |
288 { id:newrecord.get('gemId') }); | |
289 console.log(this_panel.down('verwaltungseinheit')); | |
290 this_panel.down('staat').store.load( | |
291 { id : newrecord.get('staat') }); | |
292 me.setDisabled(true); | |
293 me.hide(); | |
286 var ozw = this_panel.up().parentWindow; | 294 var ozw = this_panel.up().parentWindow; |
287 var json = Ext.decode(response.response.responseText); | 295 var json = Ext.decode(response.response.responseText); |
288 if (json) { | 296 if (json) { |
289 this_panel.clearMessages(); | 297 this_panel.clearMessages(); |
290 this_panel.setMessages(json.errors, json.warnings); | 298 this_panel.setMessages(json.errors, json.warnings); |
302 if (json) { | 310 if (json) { |
303 if (json.message == '201') { | 311 if (json.message == '201') { |
304 resulttext = 'Dieser Ort existiert bereits!'; | 312 resulttext = 'Dieser Ort existiert bereits!'; |
305 } | 313 } |
306 if (json.message == '200') { | 314 if (json.message == '200') { |
307 if (oldId === undefined) { | 315 resulttext = 'Ort erfolgreich angelegt!'; |
308 resulttext = 'Ort erfolgreich angelegt!'; | |
309 } else { | |
310 resulttext = 'Bestehender Ort erfolgreich modifiziert!'; | |
311 } | |
312 } | 316 } |
313 } | 317 } |
314 Ext.Msg.show({ | 318 Ext.Msg.show({ |
315 title: Lada.getApplication().bundle.getMsg('success'), | 319 title: Lada.getApplication().bundle.getMsg('success'), |
316 autoScroll: true, | 320 autoScroll: true, |
338 } | 342 } |
339 } else { | 343 } else { |
340 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'), | 344 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'), |
341 Lada.getApplication().bundle.getMsg('err.msg.response.body')); | 345 Lada.getApplication().bundle.getMsg('err.msg.response.body')); |
342 } | 346 } |
347 me.setDisabled(true); | |
343 } | 348 } |
344 }); | 349 }); |
345 }, | 350 }, |
346 | 351 |
347 setMessages: function(errors, warnings) { | 352 setMessages: function(errors, warnings) { |