[Lada-commits] [PATCH] correct behaviour of 'reverting changes' in ortszuordnung

Wald Commits scm-commit at wald.intevation.org
Mon Feb 6 11:29:16 CET 2017


# HG changeset patch
# User Maximilian Krambach <mkrambach at intevation.de>
# Date 1486376947 -3600
# Node ID cd16b30dbc106c07a27a7ed6c12d6295e0e8d42a
# Parent  d5e270fa91e48a7f36fd56a62d1eca47b57b63cc
correct behaviour of 'reverting changes' in ortszuordnung

diff -r d5e270fa91e4 -r cd16b30dbc10 app/controller/form/Ortszuordnung.js
--- 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);
diff -r d5e270fa91e4 -r cd16b30dbc10 app/view/form/Ortszuordnung.js
--- 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());
     }
 });


More information about the Lada-commits mailing list