changeset 1328:cf73b7d7cf99

reinserted discard button and functionality
author Maximilian Krambach <mkrambach@intevation.de>
date Fri, 03 Feb 2017 15:31:18 +0100
parents c413ec1aaa2e
children 053bd0cd9744
files app/controller/form/Ortszuordnung.js
diffstat 1 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/app/controller/form/Ortszuordnung.js	Fri Feb 03 15:26:41 2017 +0100
+++ b/app/controller/form/Ortszuordnung.js	Fri Feb 03 15:31:18 2017 +0100
@@ -23,6 +23,9 @@
             'ortszuordnungform button[action=save]': {
                 click: this.save
             },
+            'ortszuordnungform button[action=revert]': {
+                click: this.revert
+            },
             'ortszuordnungform': {
                 validitychange: this.validityChange,
                 dirtychange: this.validityChange
@@ -47,7 +50,6 @@
         }
         var data = formPanel.getForm().getFieldValues(false);
         var i18n = Lada.getApplication().bundle;
-        //TODO: the forms seem not to submit anything into record.
         var recordData = formPanel.getForm().getRecord().data;
         if (recordData['probeId'] !== undefined) {
             // TODO: as model.ort.ortId and model.ortszuordnung.ortId coexist,
@@ -110,6 +112,26 @@
     },
 
     /**
+     * reverts the form to the currently saved state
+     */
+    revert: function(button) {
+        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;
+        } else {
+            currentOrt = recordData.ort;
+        }
+        var record = osg.store.getById(currentOrt);
+        var selmod = osg.getView().getSelectionModel();
+        form.getForm().reset();
+           var selmod = osg.getView().getSelectionModel();
+        selmod.select(record);
+    },
+
+    /**
      * When the button is Active, a Record can be selected.
      * If the Record was selected from a grid this function
      * sets the ortzuordnung.

http://lada.wald.intevation.org