[Lada-commits] [PATCH] fix ortszuordnung 'revert' if record is new ortszuordnung

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


# HG changeset patch
# User Maximilian Krambach <mkrambach at intevation.de>
# Date 1486380780 -3600
# Node ID 2fc8e2b3c456502a810b70cefabb2c64bcb181c7
# Parent  8742d020c685066a10d7026071f0813547f68467
fix ortszuordnung 'revert' if record is new ortszuordnung

diff -r 8742d020c685 -r 2fc8e2b3c456 app/controller/form/Ortszuordnung.js
--- a/app/controller/form/Ortszuordnung.js	Mon Feb 06 12:02:37 2017 +0100
+++ b/app/controller/form/Ortszuordnung.js	Mon Feb 06 12:33:00 2017 +0100
@@ -113,14 +113,17 @@
         var osg = button.up('window').down('ortstammdatengrid');
         var recordData = form.getForm().getRecord().data;
         var currentOrt = recordData.ortId;
-        var record = osg.store.getById(currentOrt);
         var selmod = osg.getView().getSelectionModel();
         form.getForm().reset();
-        form.setOrt(null, record);
+        if (!currentOrt) {
+            selmod.deselectAll();
+        } else {
+            var record = osg.store.getById(currentOrt);
+            form.setOrt(null, record);
+            selmod.select(record);
+        }
         button.setDisabled(true);
         button.up('toolbar').down('button[action=save]').setDisabled(true);
-        var selmod = osg.getView().getSelectionModel();
-        selmod.select(record);
     },
 
     /**
@@ -190,12 +193,14 @@
      * is present in the toolbar of the form.
      */
     validityChange: function(form, valid) {
-        // 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
+        // the simple form.isDirty() check seems to fail for a lot of cases
+        var ortIdIsDirty = true;
+        if (form.getRecord().data.ortId == form.findField('ortId').getValue()) {
+            ortIdIsDirty = false;
+        }
         if (form.findField('ortszusatztext').isDirty()
             || form.findField('ortszuordnungTyp').isDirty()
-            || form.findField('ortId').isDirty()) {
+            || ortIdIsDirty) {
             form.owner.down('button[action=revert]').setDisabled(false);
             if (valid && form.getValues().ortId !== '') {
                 form.owner.down('button[action=save]').setDisabled(false);
diff -r 8742d020c685 -r 2fc8e2b3c456 app/view/form/Ortszuordnung.js
--- a/app/view/form/Ortszuordnung.js	Mon Feb 06 12:02:37 2017 +0100
+++ b/app/view/form/Ortszuordnung.js	Mon Feb 06 12:33:00 2017 +0100
@@ -73,6 +73,7 @@
                         qtip: 'Änderungen verwerfen',
                         icon: 'resources/img/dialog-cancel.png',
                         action: 'revert',
+                        disabled: true
                     }]
                 }],
                 items: [{
@@ -141,7 +142,9 @@
      * it will set the ortId of this record
      */
     setOrt: function(row, selRecord, index, opts) {
-        var newOrtId = selRecord.get('id');
+        if (selRecord) {
+            var newOrtId = selRecord.get('id');
+        }
         if (newOrtId) {
             this.getForm().setValues({ortId: newOrtId});
             this.setOrtInfo(selRecord);


More information about the Lada-commits mailing list