Mercurial > lada > lada-client
comparison app/view/form/Ortserstellung.js @ 1314:8ace34d9352a
changed behaviour of ortserstellung window on save; fix update (form)
author | Maximilian Krambach <mkrambach@intevation.de> |
---|---|
date | Fri, 03 Feb 2017 11:08:44 +0100 |
parents | c4ac1c09c0b0 |
children | 518b4c28e71a 3a3148d50b9c |
comparison
equal
deleted
inserted
replaced
1313:c4ac1c09c0b0 | 1314:8ace34d9352a |
---|---|
19 model: null, | 19 model: null, |
20 | 20 |
21 margin: 5, | 21 margin: 5, |
22 | 22 |
23 record: null, | 23 record: null, |
24 | |
25 trackResetOnLoad: true, | |
24 | 26 |
25 initComponent: function() { | 27 initComponent: function() { |
26 var i18n = Lada.getApplication().bundle; | 28 var i18n = Lada.getApplication().bundle; |
27 var me = this; | 29 var me = this; |
28 this.items = [{ | 30 this.items = [{ |
212 * Disables the save button if false | 214 * Disables the save button if false |
213 */ | 215 */ |
214 checkCommitEnabled: function() { | 216 checkCommitEnabled: function() { |
215 var savebutton = this.down('toolbar').down('button[action=save]'); | 217 var savebutton = this.down('toolbar').down('button[action=save]'); |
216 var form = this.getForm(); | 218 var form = this.getForm(); |
217 if (form.findField('kdaId').getValue() || | 219 if (form.isDirty()) { |
218 form.findField('koordYExtern').getValue() || | 220 if (form.findField('kdaId').getValue() || |
219 form.findField('koordXExtern').getValue()) { | 221 form.findField('koordYExtern').getValue() || |
220 if (this.checkCoordinates()) { | 222 form.findField('koordXExtern').getValue()) { |
223 if (this.checkCoordinates()) { | |
224 savebutton.setDisabled(false); | |
225 } else { | |
226 savebutton.setDisabled(true); | |
227 } | |
228 } else if (form.findField('gemId').getValue() || | |
229 form.findField('staatId').getValue() >= 0 ) { | |
221 savebutton.setDisabled(false); | 230 savebutton.setDisabled(false); |
222 } else { | 231 } else { |
223 savebutton.setDisabled(true); | 232 savebutton.setDisabled(true); |
224 } | 233 } |
225 } else if (form.findField('gemId').getValue() || | |
226 form.findField('staatId').getValue() >= 0 ) { | |
227 savebutton.setDisabled(false); | |
228 } else { | 234 } else { |
229 savebutton.setDisabled(true); | 235 savebutton.setDisabled(true); |
230 } | 236 } |
231 }, | 237 }, |
232 | 238 |
266 | 272 |
267 saveOrt: function() { | 273 saveOrt: function() { |
268 var this_panel = this.up('panel'); | 274 var this_panel = this.up('panel'); |
269 var form = this_panel.getForm(); | 275 var form = this_panel.getForm(); |
270 var record = form.getRecord(); | 276 var record = form.getRecord(); |
277 var oldId = record.get('ortId'); | |
271 var data = form.getFieldValues(true); | 278 var data = form.getFieldValues(true); |
272 for (var key in data) { | 279 for (var key in data) { |
273 record.set(key, data[key]); | 280 record.set(key, data[key]); |
274 } | 281 } |
275 record.set('netzbetreiberId', Lada.netzbetreiber[0]); | 282 record.set('netzbetreiberId', Lada.netzbetreiber[0]); |
276 record.save({ | 283 record.save({ |
277 success: function(record, response) { | 284 success: function(newrecord, response) { |
278 var newOrtId; | 285 form.loadRecord(newrecord); |
279 var ozw = this_panel.up().parentWindow; | 286 var ozw = this_panel.up().parentWindow; |
280 var json = Ext.decode(response.response.responseText); | 287 var json = Ext.decode(response.response.responseText); |
281 if (json) { | 288 if (json) { |
282 this_panel.clearMessages(); | 289 this_panel.clearMessages(); |
283 this_panel.setMessages(json.errors, json.warnings); | 290 this_panel.setMessages(json.errors, json.warnings); |
289 osg.setStore(ozw.ortstore); | 296 osg.setStore(ozw.ortstore); |
290 var id = Ext.decode(response.response.responseText).data.id; | 297 var id = Ext.decode(response.response.responseText).data.id; |
291 var record = osg.store.getById(id); | 298 var record = osg.store.getById(id); |
292 var selmod = osg.getView().getSelectionModel(); | 299 var selmod = osg.getView().getSelectionModel(); |
293 selmod.select(record); | 300 selmod.select(record); |
301 var resulttext; | |
302 if (json) { | |
303 if (json.message == '201') { | |
304 resulttext = 'Dieser Ort existiert bereits!'; | |
305 } | |
306 if (json.message == '200') { | |
307 if (oldId === undefined) { | |
308 resulttext = 'Ort erfolgreich angelegt!'; | |
309 } else { | |
310 resulttext = 'Bestehender Ort erfolgreich modifiziert!'; | |
311 } | |
312 } | |
313 } | |
294 Ext.Msg.show({ | 314 Ext.Msg.show({ |
295 title: Lada.getApplication().bundle.getMsg('success'), | 315 title: Lada.getApplication().bundle.getMsg('success'), |
296 autoScroll: true, | 316 autoScroll: true, |
297 msg: 'Ort erfolgreich angelegt!', | 317 msg: resulttext, |
298 buttons: Ext.Msg.OK | 318 buttons: Ext.Msg.OK |
299 }); | 319 }); |
300 }, | 320 }, |
301 scope: this | 321 scope: this |
302 }); | 322 }); |