Mercurial > lada > lada-client
changeset 1343:cd16b30dbc10
correct behaviour of 'reverting changes' in ortszuordnung
author | Maximilian Krambach <mkrambach@intevation.de> |
---|---|
date | Mon, 06 Feb 2017 11:29:07 +0100 |
parents | d5e270fa91e4 |
children | 195c5d9b234b |
files | app/controller/form/Ortszuordnung.js app/view/form/Ortszuordnung.js |
diffstat | 2 files changed, 18 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/app/controller/form/Ortszuordnung.js Mon Feb 06 09:59:03 2017 +0100 +++ b/app/controller/form/Ortszuordnung.js Mon Feb 06 11:29:07 2017 +0100 @@ -63,11 +63,13 @@ success: function(record, response) { var json = Ext.decode(response.response.responseText); if (json) { - button.setDisabled(true); formPanel.clearMessages(); formPanel.setRecord(record); formPanel.setMessages(json.errors, json.warnings); formPanel.up('window').parentWindow.initData(); + button.setDisabled(true); + button.up('toolbar').down( + 'button[action=revert]').setDisabled(true); } //try to refresh the Grid of the Probe try { @@ -110,16 +112,14 @@ var form = button.up('form'); var osg = button.up('window').down('ortstammdatengrid'); var recordData = form.getForm().getRecord().data; - var currentOrt = null; - if (recordData.ortId !== undefined) { - currentOrt = recordData.ortId[0]; - } else { - currentOrt = recordData.ort; - } + var currentOrt = recordData.ortId; var record = osg.store.getById(currentOrt); var selmod = osg.getView().getSelectionModel(); form.getForm().reset(); - var selmod = osg.getView().getSelectionModel(); + form.setOrt(null, record); + button.setDisabled(true); + button.up('toolbar').down('button[action=save]').setDisabled(true); + var selmod = osg.getView().getSelectionModel(); selmod.select(record); }, @@ -190,7 +190,12 @@ * is present in the toolbar of the form. */ validityChange: function(form, valid) { - if (form.isDirty()) { + // the form itself seems to be always dirty because of the ortinfo + // values put into the form at later moments. Check whether a real + // commit field is dirty + if (form.findField('ortszusatztext').isDirty() + || form.findField('ortszuordnungTyp').isDirty() + || form.findField('ortId').isDirty()) { form.owner.down('button[action=revert]').setDisabled(false); if (valid && form.getValues().ortId !== '') { form.owner.down('button[action=save]').setDisabled(false);
--- a/app/view/form/Ortszuordnung.js Mon Feb 06 09:59:03 2017 +0100 +++ b/app/view/form/Ortszuordnung.js Mon Feb 06 11:29:07 2017 +0100 @@ -156,11 +156,14 @@ var ortinfo = this.down('ortinfo'); ortinfo.loadRecord(ortrecord); ortinfo.getForm().setValues({ - gemeinde: verw.get('bezeichnung'), staat: staat.get('staatIso'), lon: ortrecord.get('longitude'), lat: ortrecord.get('latitude') }); + // some entries may not have a verwaltungseinheit + if (verw !== null) { + ortinfo.getForm().setValues({gemeinde: verw.get('bezeichnung')}); + } }, setMessages: function(errors, warnings) { @@ -215,7 +218,6 @@ var controller = Lada.app.getController( 'Lada.controller.form.Ortszuordnung'); var form = this.up('form').getForm(); - var fields = form.getFields().items; controller.validityChange(form, form.isValid()); } });