Mercurial > lada > lada-client
comparison app/controller/ModeSwitcher.js @ 978:7f5219b8e1bf stammdatengrids
Renamed the ProbePlanungSwitcher to a more generic ModeSwitcher and refactored the application
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Thu, 03 Dec 2015 09:38:43 +0100 |
parents | app/controller/ProbenPlanungSwitcher.js@fb99332bb48e |
children | af9879d72310 |
comparison
equal
deleted
inserted
replaced
977:56470a075e6e | 978:7f5219b8e1bf |
---|---|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU GPL (v>=3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out | |
6 * the documentation coming with IMIS-Labordaten-Application for details. | |
7 */ | |
8 | |
9 /** | |
10 * Controller for the ModeSwitcher | |
11 * This controller handles all logic related to the ModeSwitch | |
12 */ | |
13 Ext.define('Lada.controller.ModeSwitcher', { | |
14 extend: 'Ext.app.Controller', | |
15 displayFields: null, | |
16 | |
17 requires: [ | |
18 'Lada.store.MessprogrammQueries', | |
19 'Lada.store.ProbeQueries', | |
20 'Lada.store.StammdatenQueries' | |
21 ], | |
22 | |
23 /** | |
24 * Initialize this Controller | |
25 * It has 1 Listeners | |
26 * A checked ModeSwithch-Radiofield fired a 'check'-event | |
27 */ | |
28 init: function() { | |
29 this.control({ | |
30 'radiofield[name=modeswitch]': { | |
31 check: this.switchModes | |
32 } | |
33 }); | |
34 this.callParent(arguments); | |
35 }, | |
36 | |
37 /** | |
38 * Function is called when the user selects a checkbox. | |
39 * according to the checkboxes inputValue, | |
40 * the function alters the store which was loaded by the | |
41 * filterpanels combobox, | |
42 */ | |
43 switchModes: function(field) { | |
44 var cbox = field.up('modeswitcher').up().down('combobox'); | |
45 filters = field.up('panel[name=main]').down('fieldset[name=filtervariables]'); | |
46 filters.removeAll(); | |
47 filters.hide(); | |
48 | |
49 //Initialise variables which will define the querystore | |
50 // and the store which has to be loaded into the grid. | |
51 var querystorename = ''; | |
52 | |
53 // In dependence of the checkboxes input value, | |
54 // define the store of the filter. | |
55 // app/controller/Filter.js contains similar code. | |
56 if (field.inputValue === 'messprogramme' && cbox) { | |
57 querystorename = 'Lada.store.MessprogrammQueries'; | |
58 } | |
59 else if (field.inputValue === 'proben' && cbox) { | |
60 querystorename = 'Lada.store.ProbeQueries'; | |
61 } | |
62 else if (field.inputValue === 'stammdaten' && cbox) { | |
63 querystorename = 'Lada.store.StammdatenQueries'; | |
64 } | |
65 | |
66 if (querystorename) { | |
67 var store = Ext.StoreManager.lookup(querystorename); | |
68 | |
69 if (!store) { | |
70 store = Ext.create(querystorename, { | |
71 //Select first Item on Load | |
72 listeners: { | |
73 load: function(store){ | |
74 var records = new Array(); | |
75 records.push(store.getAt(0)); | |
76 | |
77 cbox.select(records[0]); | |
78 cbox.fireEvent('select', cbox, records); | |
79 } | |
80 } | |
81 }); | |
82 } | |
83 | |
84 if (store) { | |
85 if (!store.autoLoad) { | |
86 store.load(); | |
87 } | |
88 //cbox.reset(); | |
89 cbox.bindStore(store); | |
90 } | |
91 } | |
92 } | |
93 }); |