changeset 798:ff4330d4aba1

Filter Messtellen in Probeform and Messprogramm
author Dustin Demuth <dustin@intevation.de>
date Thu, 21 May 2015 15:23:49 +0200
parents b8fd43021c29
children ad24af3fcf89
files app.js app/controller/form/Messprogramm.js app/controller/form/Probe.js app/view/widget/Messstelle.js
diffstat 4 files changed, 46 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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'
--- 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.
--- 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
--- 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);
     }
 });

http://lada.wald.intevation.org