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'); dustin@752: filters = field.up('panel[name=main]').down('fieldset[name=filtervariables]'); dustin@752: filters.removeAll(); dustin@752: filters.hide(); dustin@975: dustin@975: //Initialise variables which will define the querystore dustin@975: // and the store which has to be loaded into the grid. dustin@975: var querystorename = ''; dustin@975: dustin@975: // In dependence of the checkboxes input value, dustin@975: // define the store of the filter. dustin@975: // app/controller/Filter.js contains similar code. dustin@975: if (field.inputValue === 'messprogramme' && cbox) { dustin@975: querystorename = 'Lada.store.MessprogrammQueries'; dustin@747: } dustin@975: else if (field.inputValue === 'proben' && cbox) { dustin@975: querystorename = 'Lada.store.ProbeQueries'; dustin@975: } dustin@975: else if (field.inputValue === 'stammdaten' && cbox) { dustin@975: querystorename = 'Lada.store.StammdatenQueries'; dustin@747: } dustin@747: dustin@975: if (querystorename) { dustin@975: var store = Ext.StoreManager.lookup(querystorename); dustin@837: dustin@975: if (!store) { dustin@975: store = Ext.create(querystorename, { dustin@975: //Select first Item on Load dustin@975: listeners: { dustin@975: load: function(store){ dustin@975: var records = new Array(); dustin@975: records.push(store.getAt(0)); dustin@795: dustin@975: cbox.select(records[0]); dustin@975: cbox.fireEvent('select', cbox, records); dustin@975: } dustin@794: } dustin@975: }); dustin@975: } dustin@975: dustin@975: if (store) { dustin@975: if (!store.autoLoad) { dustin@975: store.load(); dustin@794: } dustin@975: //cbox.reset(); dustin@975: cbox.bindStore(store); dustin@975: } dustin@747: } dustin@747: } dustin@747: });