raimund@1015: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz raimund@1015: * Software engineering by Intevation GmbH raimund@1015: * raimund@1015: * This file is Free Software under the GNU GPL (v>=3) raimund@1015: * and comes with ABSOLUTELY NO WARRANTY! Check out raimund@1015: * the documentation coming with IMIS-Labordaten-Application for details. raimund@1015: */ raimund@1015: raimund@1015: /** raimund@1015: * raimund@1015: */ raimund@1015: Ext.define('Lada.controller.FilterManagement', { raimund@1015: extend: 'Ext.app.Controller', raimund@1015: raimund@1015: /** raimund@1015: * @private raimund@1015: * Initialize the controller. raimund@1015: */ raimund@1015: init: function() { raimund@1015: var me = this; raimund@1015: this.control({ raimund@1015: 'filtermanagement grid favcolumn': { raimund@1015: checkchange: me.checkchange raimund@1015: }, raimund@1015: 'filtermanagement': { raimund@1015: close: me.windowClosed raimund@1015: } raimund@1015: }); raimund@1015: }, raimund@1015: raimund@1015: checkchange: function(column, ndx, value) { raimund@1015: var store = column.up('grid').store; raimund@1015: var record = store.getAt(ndx); raimund@1015: if (value) { raimund@1015: Ext.Ajax.request({ raimund@1015: url: 'lada-server/rest/favorite', raimund@1015: method: 'POST', raimund@1015: jsonData: { raimund@1015: 'queryId': record.get('id') raimund@1015: }, raimund@1015: success: function() { raimund@1015: record.set('favorite', true); raimund@1015: } raimund@1015: }); raimund@1015: } raimund@1015: else { raimund@1015: Ext.Ajax.request({ raimund@1015: url: 'lada-server/rest/favorite?queryId=' + record.get('id'), raimund@1015: method: 'DELETE', raimund@1015: success: function() { raimund@1015: record.set('favorite', false); raimund@1015: } raimund@1015: }); raimund@1015: } raimund@1015: }, raimund@1015: raimund@1015: windowClosed: function() { raimund@1015: var combobox = Ext.ComponentQuery.query('combobox[name=filter]')[0]; raimund@1015: this.getController('Lada.controller.Filter').updateFilter(combobox); raimund@1015: } raimund@1015: });