dustin@747: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
dustin@747:  * Software engineering by Intevation GmbH
dustin@747:  *
dustin@747:  * This file is Free Software under the GNU GPL (v>=3)
dustin@747:  * and comes with ABSOLUTELY NO WARRANTY! Check out
dustin@747:  * the documentation coming with IMIS-Labordaten-Application for details.
dustin@747:  */
dustin@747: 
dustin@747: /**
dustin@978:  * Controller for the ModeSwitcher
dustin@978:  * This controller handles all logic related to the ModeSwitch
dustin@747:  */
dustin@978: Ext.define('Lada.controller.ModeSwitcher', {
dustin@747:     extend: 'Ext.app.Controller',
dustin@747:     displayFields: null,
dustin@747: 
raimund@749:     requires: [
dustin@908:         'Lada.store.MessprogrammQueries',
dustin@975:         'Lada.store.ProbeQueries',
dustin@975:         'Lada.store.StammdatenQueries'
raimund@749:     ],
raimund@749: 
dustin@747:     /**
dustin@747:      * Initialize this Controller
dustin@747:      * It has 1 Listeners
dustin@978:      * A checked ModeSwithch-Radiofield fired a 'check'-event
dustin@747:      */
dustin@747:     init: function() {
dustin@747:         this.control({
dustin@978:             'radiofield[name=modeswitch]': {
dustin@792:                 check: this.switchModes
dustin@747:             }
dustin@747:         });
dustin@747:         this.callParent(arguments);
dustin@747:     },
dustin@747: 
dustin@747:     /**
dustin@747:      * Function is called when the user selects a checkbox.
dustin@747:      * according to the checkboxes inputValue,
dustin@747:      * the function alters the store which was loaded by the
dustin@792:      * filterpanels combobox,
dustin@747:      */
dustin@792:     switchModes: function(field) {
dustin@978:         var cbox = field.up('modeswitcher').up().down('combobox');
raimund@1016:         var filterValues = field.up('panel[name=main]').down('panel[name=filtervalues]');
raimund@1016:         var filters = field.up('panel[name=main]').down('panel[name=filtervariables]');
raimund@1016:         filterValues.removeAll();
dustin@752:         filters.hide();
dustin@975: 
raimund@1015:         var filterController = this.getController('Lada.controller.Filter');
raimund@1015:         filterController.mode = field.inputValue;
raimund@1015:         filterController.updateFilter(cbox);
dustin@747:     }
dustin@747: });