Mercurial > lada > lada-client
view app/controller/Sql.js @ 499:8b4ec61c5752
Removed most log messages to make the application less verbose.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 06 Nov 2014 11:12:21 +0100 |
parents | 9fec6df13be8 |
children | ad7f574b382a |
line wrap: on
line source
/* 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. */ var queries = new Array('query1', 'query2'); /** * Controller for the Search * This controller handles all logic related to the search */ Ext.define('Lada.controller.Sql', { extend: 'Ext.app.Controller', requires: [ 'Lada.view.widgets.Mst', 'Lada.view.widgets.Uwb', 'Lada.view.widgets.Datetime', 'Lada.view.About' ], stores: [ 'Proben', // List of found Proben 'ProbenList', // List of found Proben 'Queries', 'Info' ], init: function() { this.control({ // CSS like selector to select element in the viewport. See // ComponentQuery documentation for more details. '#search': { // Map Doubleclick on rows of the probenlist. select: this.selectSql }, '#SearchBtn': { // Map click event on Button. click: this.search }, '#ResetBtn': { // Map click event on Button. click: this.reset }, '#AboutBtn': { // Map click event on Button. click: this.about } }); this.callParent(arguments); }, /** * Function called when the user selects a SQL query in the dropdownlist. * The function will hide/display additional element related to the * selected search query */ selectSql: function(element, record, index) { var result = Ext.getCmp('result'); var filters = Ext.getCmp('queryfilters'); var sqlquery = Ext.getCmp('sqlquery'); var sqldesc = Ext.getCmp('sqldesc'); var buttons = Ext.getCmp('SearchBtnPanel'); var displayFields = record[0].data.results; var filterFields = record[0].data.filters; this.reset(); sqlquery.setValue(record[0].data.sql); sqldesc.setValue(record[0].data.description); // Setup Columns of the probenlist displayFields.reverse(); result.setupColumns(displayFields); // Setup Filters of the probenlist // // Allowed types are // * text // * number // * datetime // * bool // * listmst // * listumw // * listver // * listdbasis // * listnetz // // Iterate over all configured filters and add filters dynamically // // 1. Empty filters filters.removeAll(); var hide = true; // 2. Iterate over all configured filters for (var j=0; j < filterFields.length; j++) { var type = filterFields[j].type; var name = filterFields[j].dataIndex; var label = filterFields[j].label; var multi = filterFields[j].multiSelect; var field = null; if (type == "text") { field = Ext.create('Ext.form.field.Text', { name: name, fieldLabel: label }); } else if (type == "number") { field = Ext.create('Ext.form.field.Number', { name: name, fieldLabel: label }); } else if (type == "datetime") { field = Ext.create('Lada.view.widgets.Datetime', { name: name, fieldLabel: label }); } else if (type == "bool") { field = Ext.create('Lada.view.widgets.Testdatensatz', { name: name, fieldLabel: label, emptyText: '' }); } else if (type == "listmst") { field = Ext.create('Lada.view.widgets.Mst', { name: name, fieldLabel: label, multiSelect: multi }); } else if (type == "listumw") { field = Ext.create('Lada.view.widgets.Uwb', { name: name, fieldLabel: label, multiSelect: multi }); } else if (type == "listdbasis") { field = Ext.create('Lada.view.widgets.Datenbasis', { name: name, fieldLabel: label, multiSelect: multi }); } else if (type == "listver") { field = Ext.create('Lada.view.widgets.Verwaltungseinheit', { name: name, fieldLabel: label, multiSelect: multi }); } else if (type == "listnetz") { field = Ext.create('Lada.view.widgets.Netzbetreiber', { name: name, fieldLabel: label, multiSelect: multi }); } if (field) { filters.add(field); filters.show(); hide = false; } } if (hide) { filters.hide(); } buttons.show(); }, /** * Function is called when the user clicks the search button. The function * will perform a search to the server on refreshes the result list. */ search: function(element, record, index) { var result = Ext.getCmp('result'); var filters = Ext.getCmp('queryfilters'); var search = Ext.getCmp('search'); // Get search parameters: var searchParams = {}; searchParams['qid'] = search.getValue(); for (var i = filters.items.length - 1; i >= 0; i--) { var filter = filters.items.items[i]; var value = filter.getValue(); if (value instanceof Array) { value = value.join(","); } searchParams[filter.getName()] = value; } result.getStore().load({ params: searchParams }); result.show(); }, reset: function(element, record, index) { var buttons = Ext.getCmp('SearchBtnPanel'); var result = Ext.getCmp('result'); //for (var i = 0; i < queries.length; ++i) { // var toHide = Ext.getCmp(queries[i]); // toHide.hide(); //} //result.hide(); //buttons.hide(); }, about: function(element, record, index) { var info = this.getInfoStore(); var view = Ext.widget('about', { info: info }); } });