[Lada-commits] [PATCH] Filter Messtellen in Probeform and Messprogramm

Wald Commits scm-commit at wald.intevation.org
Thu May 21 15:24:20 CEST 2015


# HG changeset patch
# User Dustin Demuth <dustin at intevation.de>
# Date 1432214629 -7200
# Node ID ff4330d4aba13b5c08684383acf1824cda767058
# Parent  b8fd43021c2979922847238d6b56f8e61a51fe0b
Filter Messtellen in Probeform and Messprogramm

diff -r b8fd43021c29 -r ff4330d4aba1 app.js
--- a/app.js	Wed May 20 16:48:03 2015 +0200
+++ b/app.js	Thu May 21 15:23:49 2015 +0200
@@ -60,6 +60,7 @@
         Lada.username = '';
         Lada.userroles = '';
         Lada.logintime = '';
+        Lada.mst = [];
 
         var queryString = document.location.href.split('?')[1];
         if (queryString) {
@@ -118,6 +119,7 @@
         Lada.username = json.data.username;
         Lada.userroles = json.data.roles;
         Lada.logintime = json.data.servertime;
+        Lada.mst = json.data.mst; //Store Messstellen this user may select
 
         Ext.create('Lada.store.Datenbasis', {
             storeId: 'datenbasis'
diff -r b8fd43021c29 -r ff4330d4aba1 app/controller/form/Messprogramm.js
--- a/app/controller/form/Messprogramm.js	Wed May 20 16:48:03 2015 +0200
+++ b/app/controller/form/Messprogramm.js	Thu May 21 15:23:49 2015 +0200
@@ -33,6 +33,10 @@
             'messprogrammform': {
                 dirtychange: this.dirtyForm
             },
+            'messprogrammform messstelle combobox':{
+                expand: this.filter,
+                keydown: this.filter
+            },
             'messprogrammform location combobox': {
                 select: this.syncOrtWindow
             },
@@ -55,6 +59,24 @@
             }
         });
     },
+
+    /**
+     * The Messtellen Store contains ALL Messtellen.
+     * Filter the store in this combobox to reduce the choices
+     * to the subset which the user is allowed to use.
+     */
+    filter: function(field) {
+        var fil =  Ext.create('Ext.util.Filter', {
+            filterFn: function(item) {
+                if (Ext.Array.contains(Lada.mst, item.get('id'))) {
+                    return true;
+                }
+                return false;
+            }
+        });
+        field.getStore().filter(fil);
+    },
+
     /**
      * When the Probenintervall was changed, update the Sliders
      * and the the numberfield.
diff -r b8fd43021c29 -r ff4330d4aba1 app/controller/form/Probe.js
--- a/app/controller/form/Probe.js	Wed May 20 16:48:03 2015 +0200
+++ b/app/controller/form/Probe.js	Thu May 21 15:23:49 2015 +0200
@@ -27,6 +27,10 @@
             'probeform': {
                 dirtychange: this.dirtyForm
             },
+            'probeform messstelle combobox':{
+                expand: this.filter,
+                keydown: this.filter
+            },
             'probeform [xtype="datetime"] field': {
                 blur: this.checkDate
             },
@@ -37,6 +41,23 @@
     },
 
     /**
+     * The Messtellen Store contains ALL Messtellen.
+     * Filter the store in this combobox to reduce the choices
+     * to the subset which the user is allowed to use.
+     */
+    filter: function(field) {
+        var fil =  Ext.create('Ext.util.Filter', {
+            filterFn: function(item) {
+                if (Ext.Array.contains(Lada.mst, item.get('id'))) {
+                    return true;
+                }
+                return false;
+            }
+        });
+        field.getStore().filter(fil);
+    },
+
+    /**
      * The save function saves the content of the Location form.
      * On success it will reload the Store,
      * on failure, it will display an Errormessage
diff -r b8fd43021c29 -r ff4330d4aba1 app/view/widget/Messstelle.js
--- a/app/view/widget/Messstelle.js	Wed May 20 16:48:03 2015 +0200
+++ b/app/view/widget/Messstelle.js	Thu May 21 15:23:49 2015 +0200
@@ -30,6 +30,7 @@
         if (!this.store) {
             this.store = Ext.create('Lada.store.Messstellen');
         }
+        this.store.clearFilter(true);
         this.callParent(arguments);
     }
 });


More information about the Lada-commits mailing list