Mercurial > lada > lada-client
changeset 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 | d312e514875c |
files | app/controller/grid/Ortszuordnung.js app/view/form/Ortserstellung.js |
diffstat | 2 files changed, 32 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/app/controller/grid/Ortszuordnung.js Fri Feb 03 09:47:52 2017 +0100 +++ b/app/controller/grid/Ortszuordnung.js Fri Feb 03 11:08:44 2017 +0100 @@ -172,7 +172,8 @@ var grid = button.up('ortszuordnungwindow').down('ortstammdatengrid').getView(); var selected = grid.getSelectionModel().getSelection()[0]; var newRecord = Ext.create('Lada.model.Ort', selected.data); - newRecord.set('ortId', ''); + newRecord.set('ortId', null); + newRecord.set('id', null); Ext.create('Lada.view.window.Ortserstellung', { record: newRecord, parentWindow: button.up('ortszuordnungwindow')
--- a/app/view/form/Ortserstellung.js Fri Feb 03 09:47:52 2017 +0100 +++ b/app/view/form/Ortserstellung.js Fri Feb 03 11:08:44 2017 +0100 @@ -22,6 +22,8 @@ record: null, + trackResetOnLoad: true, + initComponent: function() { var i18n = Lada.getApplication().bundle; var me = this; @@ -214,17 +216,21 @@ checkCommitEnabled: function() { var savebutton = this.down('toolbar').down('button[action=save]'); var form = this.getForm(); - if (form.findField('kdaId').getValue() || - form.findField('koordYExtern').getValue() || - form.findField('koordXExtern').getValue()) { - if (this.checkCoordinates()) { + if (form.isDirty()) { + if (form.findField('kdaId').getValue() || + form.findField('koordYExtern').getValue() || + form.findField('koordXExtern').getValue()) { + if (this.checkCoordinates()) { + savebutton.setDisabled(false); + } else { + savebutton.setDisabled(true); + } + } else if (form.findField('gemId').getValue() || + form.findField('staatId').getValue() >= 0 ) { savebutton.setDisabled(false); } else { savebutton.setDisabled(true); } - } else if (form.findField('gemId').getValue() || - form.findField('staatId').getValue() >= 0 ) { - savebutton.setDisabled(false); } else { savebutton.setDisabled(true); } @@ -268,14 +274,15 @@ var this_panel = this.up('panel'); var form = this_panel.getForm(); var record = form.getRecord(); + var oldId = record.get('ortId'); var data = form.getFieldValues(true); for (var key in data) { record.set(key, data[key]); } record.set('netzbetreiberId', Lada.netzbetreiber[0]); record.save({ - success: function(record, response) { - var newOrtId; + success: function(newrecord, response) { + form.loadRecord(newrecord); var ozw = this_panel.up().parentWindow; var json = Ext.decode(response.response.responseText); if (json) { @@ -291,10 +298,23 @@ var record = osg.store.getById(id); var selmod = osg.getView().getSelectionModel(); selmod.select(record); + var resulttext; + if (json) { + if (json.message == '201') { + resulttext = 'Dieser Ort existiert bereits!'; + } + if (json.message == '200') { + if (oldId === undefined) { + resulttext = 'Ort erfolgreich angelegt!'; + } else { + resulttext = 'Bestehender Ort erfolgreich modifiziert!'; + } + } + } Ext.Msg.show({ title: Lada.getApplication().bundle.getMsg('success'), autoScroll: true, - msg: 'Ort erfolgreich angelegt!', + msg: resulttext, buttons: Ext.Msg.OK }); },