changeset 842:beef4e8eeafc

Added logic to autofill the Netzbetreiber when the Messstelle was selected.
author Dustin Demuth <dustin@intevation.de>
date Tue, 07 Jul 2015 09:55:37 +0200
parents cf35c6305370
children 05124d559e59
files app/controller/form/Messprogramm.js
diffstat 1 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/app/controller/form/Messprogramm.js	Tue Jul 07 09:37:34 2015 +0200
+++ b/app/controller/form/Messprogramm.js	Tue Jul 07 09:55:37 2015 +0200
@@ -35,7 +35,8 @@
             },
             'messprogrammform messstelle combobox':{
                 expand: this.filter,
-                keydown: this.filter
+                keydown: this.filter,
+                select: this.setNetzbetreiber
             },
             'messprogrammform location combobox': {
                 select: this.syncOrtWindow
@@ -78,6 +79,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);
+        }
+    },
+
+    /**
      * When the Probenintervall was changed, update the Sliders
      * and the the numberfield.
      */

http://lada.wald.intevation.org