[Lada-commits] [PATCH 2 of 5] Renamed the ProbePlanungSwitcher to a more generic ModeSwitcher and refactored the application

Wald Commits scm-commit at wald.intevation.org
Fri Dec 4 15:29:18 CET 2015


# HG changeset patch
# User Dustin Demuth <dustin at intevation.de>
# Date 1449131923 -3600
# Branch stammdatengrids
# Node ID 7f5219b8e1bf0464f469da04552ae16b92f8229a
# Parent  56470a075e6e4b8ce705c01a8ba7d9ed766cd308
Renamed the ProbePlanungSwitcher to a more generic ModeSwitcher and refactored the application

diff -r 56470a075e6e -r 7f5219b8e1bf app.js
--- a/app.js	Thu Dec 03 09:26:43 2015 +0100
+++ b/app.js	Thu Dec 03 09:38:43 2015 +0100
@@ -201,6 +201,7 @@
     // first before the application "launch" function is called.
     controllers: [
         'Lada.controller.Filter',
+        'Lada.controller.ModeSwitcher',
         'Lada.controller.grid.ProbeList',
         'Lada.controller.grid.MessprogrammeList',
         'Lada.controller.form.Probe',
@@ -215,7 +216,6 @@
         'Lada.controller.grid.Status',
         'Lada.controller.Map',
         'Lada.controller.form.Location',
-        'Lada.controller.ProbenPlanungSwitcher',
         'Lada.controller.form.Messprogramm',
         'Lada.controller.grid.Messmethode'
         ]
diff -r 56470a075e6e -r 7f5219b8e1bf app/controller/ModeSwitcher.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/controller/ModeSwitcher.js	Thu Dec 03 09:38:43 2015 +0100
@@ -0,0 +1,93 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+
+/**
+ * Controller for the ModeSwitcher
+ * This controller handles all logic related to the ModeSwitch
+ */
+Ext.define('Lada.controller.ModeSwitcher', {
+    extend: 'Ext.app.Controller',
+    displayFields: null,
+
+    requires: [
+        'Lada.store.MessprogrammQueries',
+        'Lada.store.ProbeQueries',
+        'Lada.store.StammdatenQueries'
+    ],
+
+    /**
+     * Initialize this Controller
+     * It has 1 Listeners
+     * A checked ModeSwithch-Radiofield fired a 'check'-event
+     */
+    init: function() {
+        this.control({
+            'radiofield[name=modeswitch]': {
+                check: this.switchModes
+            }
+        });
+        this.callParent(arguments);
+    },
+
+    /**
+     * Function is called when the user selects a checkbox.
+     * according to the checkboxes inputValue,
+     * the function alters the store which was loaded by the
+     * filterpanels combobox,
+     */
+    switchModes: function(field) {
+        var cbox = field.up('modeswitcher').up().down('combobox');
+        filters = field.up('panel[name=main]').down('fieldset[name=filtervariables]');
+        filters.removeAll();
+        filters.hide();
+
+        //Initialise variables which will define the querystore
+        // and the store which has to be loaded into the grid.
+        var querystorename = '';
+
+        // In dependence of the checkboxes input value,
+        // define the store of the filter.
+        //    app/controller/Filter.js contains similar code.
+        if (field.inputValue === 'messprogramme' && cbox) {
+            querystorename = 'Lada.store.MessprogrammQueries';
+        }
+        else if (field.inputValue === 'proben' && cbox) {
+            querystorename = 'Lada.store.ProbeQueries';
+        }
+        else if (field.inputValue === 'stammdaten' && cbox) {
+            querystorename = 'Lada.store.StammdatenQueries';
+        }
+
+        if (querystorename) {
+            var store = Ext.StoreManager.lookup(querystorename);
+
+            if (!store) {
+                store = Ext.create(querystorename, {
+                    //Select first Item on Load
+                    listeners: {
+                        load: function(store){
+                            var records = new Array();
+                            records.push(store.getAt(0));
+
+                            cbox.select(records[0]);
+                            cbox.fireEvent('select', cbox, records);
+                        }
+                    }
+                });
+            }
+
+            if (store) {
+                if (!store.autoLoad) {
+                    store.load();
+                }
+                //cbox.reset();
+                cbox.bindStore(store);
+            }
+        }
+    }
+});
diff -r 56470a075e6e -r 7f5219b8e1bf app/controller/ProbenPlanungSwitcher.js
--- a/app/controller/ProbenPlanungSwitcher.js	Thu Dec 03 09:26:43 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU GPL (v>=3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out
- * the documentation coming with IMIS-Labordaten-Application for details.
- */
-
-/**
- * Controller for the ProbenPlanungSwitcher
- * This controller handles all logic related to the PPS
- */
-Ext.define('Lada.controller.ProbenPlanungSwitcher', {
-    extend: 'Ext.app.Controller',
-    displayFields: null,
-
-    requires: [
-        'Lada.store.MessprogrammQueries',
-        'Lada.store.ProbeQueries',
-        'Lada.store.StammdatenQueries'
-    ],
-
-    /**
-     * Initialize this Controller
-     * It has 1 Listeners
-     * A checked PPS-Radiofield fired a 'check'-event
-     */
-    init: function() {
-        this.control({
-            'radiofield[name=ppswitch]': {
-                check: this.switchModes
-            }
-        });
-        this.callParent(arguments);
-    },
-
-    /**
-     * Function is called when the user selects a checkbox.
-     * according to the checkboxes inputValue,
-     * the function alters the store which was loaded by the
-     * filterpanels combobox,
-     */
-    switchModes: function(field) {
-        var cbox = field.up('probenplanungswitcher').up().down('combobox');
-        filters = field.up('panel[name=main]').down('fieldset[name=filtervariables]');
-        filters.removeAll();
-        filters.hide();
-
-        //Initialise variables which will define the querystore
-        // and the store which has to be loaded into the grid.
-        var querystorename = '';
-
-        // In dependence of the checkboxes input value,
-        // define the store of the filter.
-        //    app/controller/Filter.js contains similar code.
-        if (field.inputValue === 'messprogramme' && cbox) {
-            querystorename = 'Lada.store.MessprogrammQueries';
-        }
-        else if (field.inputValue === 'proben' && cbox) {
-            querystorename = 'Lada.store.ProbeQueries';
-        }
-        else if (field.inputValue === 'stammdaten' && cbox) {
-            querystorename = 'Lada.store.StammdatenQueries';
-        }
-
-        if (querystorename) {
-            var store = Ext.StoreManager.lookup(querystorename);
-
-            if (!store) {
-                store = Ext.create(querystorename, {
-                    //Select first Item on Load
-                    listeners: {
-                        load: function(store){
-                            var records = new Array();
-                            records.push(store.getAt(0));
-
-                            cbox.select(records[0]);
-                            cbox.fireEvent('select', cbox, records);
-                        }
-                    }
-                });
-            }
-
-            if (store) {
-                if (!store.autoLoad) {
-                    store.load();
-                }
-                //cbox.reset();
-                cbox.bindStore(store);
-            }
-        }
-    }
-});
diff -r 56470a075e6e -r 7f5219b8e1bf app/view/ModeSwitcher.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/ModeSwitcher.js	Thu Dec 03 09:38:43 2015 +0100
@@ -0,0 +1,66 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+
+/**
+ * This is a Widget for a ModeSwitcher
+ */
+Ext.define('Lada.view.ModeSwitcher', {
+    extend: 'Ext.form.FieldSet',
+    alias: 'widget.modeswitcher',
+
+    mixins: {
+        observable: 'Ext.util.Observable'
+    },
+    /**
+     * Initialise the Widget.
+     * When the Checkbox is checked, it fires a 'check' Event
+     */
+    initComponent: function() {
+        var i18n = Lada.getApplication().bundle;
+        this.title = i18n.getMsg('modus');
+        this.items= [{
+            xtype: 'radiogroup',
+            columns: 1,
+            width: '100%',
+            items: [{
+                xtype: 'radiofield',
+                name: 'modeswitch',
+                boxLabel: i18n.getMsg('proben'),
+                inputValue: 'proben', //this determines the store
+                    // which will be loaded by the controller,
+                checked: true,
+                handler: function(field, state){
+                    if (state === true) {
+                        this.fireEvent('check', field);
+                    }
+                }
+            },{
+                xtype: 'radiofield',
+                name: 'modeswitch',
+                boxLabel: i18n.getMsg('messprogramme'),
+                inputValue: 'messprogramme',
+                handler: function(field, state){
+                    if (state === true) {
+                        this.fireEvent('check', field);
+                    }
+                }
+            },{
+                xtype: 'radiofield',
+                name: 'modeswitch',
+                boxLabel: i18n.getMsg('stammdaten'),
+                inputValue: 'stammdaten',
+                handler: function(field, state){
+                    if (state === true) {
+                        this.fireEvent('check', field);
+                    }
+                }
+            }]
+        }];
+        this.callParent(arguments);
+    }
+});
diff -r 56470a075e6e -r 7f5219b8e1bf app/view/ProbenPlanungSwitcher.js
--- a/app/view/ProbenPlanungSwitcher.js	Thu Dec 03 09:26:43 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU GPL (v>=3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out
- * the documentation coming with IMIS-Labordaten-Application for details.
- */
-
-/**
- * This is a Widget for a ProbenPlanungSwitcher
- */
-Ext.define('Lada.view.ProbenPlanungSwitcher', {
-    extend: 'Ext.form.FieldSet',
-    alias: 'widget.probenplanungswitcher',
-
-    mixins: {
-        observable: 'Ext.util.Observable'
-    },
-    /**
-     * Initialise the Widget.
-     * When the Checkbox is checked, it fires a 'check' Event
-     */
-    initComponent: function() {
-        var i18n = Lada.getApplication().bundle;
-        this.title = i18n.getMsg('modus');
-        this.items= [{
-            xtype: 'radiogroup',
-            columns: 1,
-            width: '100%',
-            items: [{
-                xtype: 'radiofield',
-                name: 'ppswitch',
-                boxLabel: i18n.getMsg('proben'),
-                inputValue: 'proben', //this determines the store
-                    // which will be loaded by the controller,
-                checked: true,
-                handler: function(field, state){
-                    if (state === true) {
-                        this.fireEvent('check', field);
-                    }
-                }
-            },{
-                xtype: 'radiofield',
-                name: 'ppswitch',
-                boxLabel: i18n.getMsg('messprogramme'),
-                inputValue: 'messprogramme',
-                handler: function(field, state){
-                    if (state === true) {
-                        this.fireEvent('check', field);
-                    }
-                }
-            },{
-                xtype: 'radiofield',
-                name: 'ppswitch',
-                boxLabel: i18n.getMsg('stammdaten'),
-                inputValue: 'stammdaten',
-                handler: function(field, state){
-                    if (state === true) {
-                        this.fireEvent('check', field);
-                    }
-                }
-            }]
-        }];
-        this.callParent(arguments);
-    }
-});
diff -r 56470a075e6e -r 7f5219b8e1bf app/view/Viewport.js
--- a/app/view/Viewport.js	Thu Dec 03 09:26:43 2015 +0100
+++ b/app/view/Viewport.js	Thu Dec 03 09:38:43 2015 +0100
@@ -16,7 +16,7 @@
 Ext.define('Lada.view.Viewport', {
     extend: 'Ext.container.Viewport',
     requires: [
-        'Lada.view.ProbenPlanungSwitcher',
+        'Lada.view.ModeSwitcher',
         'Lada.view.FilterPanel'
     ],
     layout: 'fit',
@@ -59,7 +59,7 @@
                     }]
                 }],
                 items: [{
-                    xtype: 'probenplanungswitcher',
+                    xtype: 'modeswitcher',
                     margin: '0, 10, 0, 10'
                 }, {
                     // Auswahl einer Abfrage.


More information about the Lada-commits mailing list