diff app/controller/form/Probe.js @ 841:cf35c6305370

Added logic to autofill the Netzbetreiber when the Messstelle was selected.
author Dustin Demuth <dustin@intevation.de>
date Tue, 07 Jul 2015 09:37:34 +0200
parents ebc275959f81
children 05124d559e59
line wrap: on
line diff
--- a/app/controller/form/Probe.js	Mon Jul 06 16:58:12 2015 +0200
+++ b/app/controller/form/Probe.js	Tue Jul 07 09:37:34 2015 +0200
@@ -29,7 +29,8 @@
             },
             'probeform messstelle combobox':{
                 expand: this.filter,
-                keydown: this.filter
+                keydown: this.filter,
+                select: this.setNetzbetreiber
             },
             'probeform [xtype="datetime"] field': {
                 blur: this.checkDate
@@ -58,6 +59,25 @@
     },
 
     /**
+     * When a Messtelle is selected, modify the Netzbetreiber
+     * according to the Messstelle
+     * TODO: The conditions when to apply this automatism are still
+     *   unclear. Right now it is only applied when the NB is not set.
+     */
+    setNetzbetreiber: function(combo, records){
+        var netzbetreiber = combo.up().up('form')
+                .down('netzbetreiber').down('combobox');
+        var nbId = records[0].get('netzbetreiberId');
+
+        debugger;
+        if (nbId != null &&
+               (netzbetreiber.value === '' || netzbetreiber.value === null)) {
+            //select the NB in the NB-Combobox
+            netzbetreiber.select(nbId);
+        }
+    },
+
+    /**
      * The save function saves the content of the Location form.
      * On success it will reload the Store,
      * on failure, it will display an Errormessage

http://lada.wald.intevation.org