# HG changeset patch # User Raimund Renkert # Date 1485448436 -3600 # Node ID e317ba349204f582b55d03ea275bf7283333e52e # Parent 8b21a3fa6e1f62cec8ec9be07c9f98d27a52aec2 Added search for orte, verwaltungseinheiten and staaten. diff -r 8b21a3fa6e1f -r e317ba349204 app.js --- a/app.js Thu Jan 26 17:33:18 2017 +0100 +++ b/app.js Thu Jan 26 17:33:56 2017 +0100 @@ -10,7 +10,8 @@ enabled: true, paths: { 'Ext.i18n': 'resources/lib/ext/i18n/', - 'Ext.ux.upload': 'resources/lib/ext/upload' + 'Ext.ux.upload': 'resources/lib/ext/upload', + 'Ext.ux.util': 'resources/lib/ext/util' } }); @@ -319,6 +320,7 @@ 'Lada.controller.form.Messprogramm', 'Lada.controller.grid.MessprogrammKategorie', 'Lada.controller.grid.Messmethode', - 'Lada.controller.FilterManagement' + 'Lada.controller.FilterManagement', + 'Ext.ux.util.AlwaysOnTop' ] }); diff -r 8b21a3fa6e1f -r e317ba349204 app/controller/grid/Ortszuordnung.js --- a/app/controller/grid/Ortszuordnung.js Thu Jan 26 17:33:18 2017 +0100 +++ b/app/controller/grid/Ortszuordnung.js Thu Jan 26 17:33:56 2017 +0100 @@ -14,9 +14,13 @@ requires: [ 'Lada.view.window.Ortszuordnung', - 'Lada.view.window.Ortserstellung' + 'Lada.view.form.Ortserstellung', + 'Lada.view.window.OrtFilter' ], + resultPanel: null, + searchField: null, + /** * Inhitialize the controller * It has 3 listeners @@ -40,6 +44,18 @@ }, 'ortszuordnungwindow toolbar button[action=clone]':{ click: this.cloneort + }, + 'ortszuordnungwindow toolbar textfield[name=search]': { + keyup: this.search + }, + 'ortfilterwindow grid[name=messpunkte]': { + itemdblclick: this.selectedMesspunkt + }, + 'ortfilterwindow grid[name=verwaltungseinheiten]': { + itemdblclick: this.selectedVerwaltungseinheit + }, + 'ortfilterwindow grid[name=staaten]': { + itemdblclick: this.selectedStaat } }); }, @@ -119,21 +135,25 @@ * Opens the form for a new Messpunkt */ createort: function() { - Ext.create('Lada.view.window.Ortserstellung',{ - parentWindow: button.up('ortszuordnungwindow') - }).show(); + Ext.create('Lada.view.form.Ortserstellung').show(); }, /** * - * Creates an event listener for a map click + * Opens the form for a new Messpunkt, with prefilled coordinates. + * TODO Not functional yet */ frommap: function(button) { var map = button.up('ortszuordnungwindow').down('map'); - var me = this; - map.map.events.register('click', button, me.newOrtfromMapClick); - // TODO visual feedback that map click is active. - // TODO Deactivate event listener if button is destroyed + // map.getClick(); + //TODO: wait for click return + Ext.create('Lada.view.form.Ortserstellung', { + presets: { + kda_id: 4, + koord_x_extern: 35000000, //TODO dummy values + koord_y_extern: 1000000 + } + }).show(); }, /** @@ -143,29 +163,96 @@ cloneort: function(button) { var grid = button.up('ortszuordnungwindow').down('ortstammdatengrid').getView(); var selected = grid.getSelectionModel().getSelection()[0]; - Ext.create('Lada.view.window.Ortserstellung', { - record: Ext.create('Lada.model.Ort', selected.data), - parentWindow: button.up('ortszuordnungwindow') + Ext.create('Lada.view.form.Ortserstellung', { + presets: selected.data }).show(); }, /** - * Gets the clicked map's coordinates and opens a new Messpunkt window with coordinates prefilled + * Search triggered by textfield key event. */ - newOrtfromMapClick: function(evt) { - var me = this; //this = button(action:frommap) - var map = this.up('ortszuordnungwindow').down('map').map; - var lonlat = map.getLonLatFromViewPortPx(evt.xy).transform(new OpenLayers.Projection('EPSG:3857'), - new OpenLayers.Projection('EPSG:4326')); - var controller = Lada.app.getController('Lada.controller.grid.Ortszuordnung'); - map.events.unregister('click', this, controller.newOrtfromMapClick); - Ext.create('Lada.view.window.Ortserstellung', { - record: Ext.create('Lada.model.Ort',{ - koordXExtern: lonlat.lon, - koordYExtern: lonlat.lat, - kdaId : 4 - }), - parentWindow: this.up('ortszuordnungwindow') - }).show(); + search: function(field, evt, opts) { + this.searchField = field; + if ((evt.getKey() == 13 || evt.getKey() == 8) && field.getValue() && field.getValue().length > 0) { + this.execSearch(field, field.getValue()); + } + if (field.getValue().length === 0) { + this.resultPanel.hide(); + return; + } + if (field.getValue().length < 3) { + return; + } + this.execSearch(field, field.getValue()); + }, + + /* + * Execute search in stores (ort, verwaltungseinheit and staat) and + * display the resultset. + */ + execSearch: function(field, filter) { + // Filter stores + var messpunkte = Ext.data.StoreManager.get('orte'); + var verwaltungseinheiten = Ext.data.StoreManager.get('verwaltungseinheiten'); + var staaten = Ext.data.StoreManager.get('staaten'); + messpunkte.clearFilter(true); + verwaltungseinheiten.clearFilter(true); + staaten.clearFilter(true); + messpunkte.filter({filterFn: function(item) { + if (item.get('ortId').indexOf(filter) > -1) { + return true; + } + if (item.get('kurztext').indexOf(filter) > -1) { + return true; + } + if (item.get('langtext').indexOf(filter) > -1) { + return true; + } + if (item.get('berichtstext') && + item.get('berichtstext').indexOf(filter) > -1) { + return true; + } + if (item.get('gemId').indexOf(filter) > -1) { + return true; + } + }}); + verwaltungseinheiten.filter('bezeichnung', filter); + staaten.filter('staat', filter); + + if (!this.resultPanel) { + this.resultPanel = Ext.create('Lada.view.window.OrtFilter', { + x: 500, + y: 500, + alwaysOnTop: true + }); + } + this.resultPanel.show(); + this.resultPanel.updateGrids(messpunkte, verwaltungseinheiten, staaten); + this.resultPanel.reposition(field.getX() + field.getLabelWidth(), field.getY()); + field.focus(); + }, + + selectedMesspunkt: function(grid, record) { + var win = grid.up('window'); + win.hide(); + this.searchField.reset(); + var grid = this.searchField.up('panel').down('ortstammdatengrid'); + grid.getSelectionModel().select(record); + grid.getView().focusRow(record); + console.log(record); + }, + + selectedVerwaltungseinheit: function(grid, record) { + var win = grid.up('window'); + win.hide(); + this.searchField.reset(); + console.log(record); + }, + + selectedStaat: function(grid, record) { + var win = grid.up('window'); + win.hide(); + this.searchField.reset(); + console.log(record); } }); diff -r 8b21a3fa6e1f -r e317ba349204 app/view/window/OrtFilter.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/view/window/OrtFilter.js Thu Jan 26 17:33:56 2017 +0100 @@ -0,0 +1,130 @@ +/* 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. + */ + +/** + * Panel for universal orte search resultset. + * + */ +Ext.define('Lada.view.window.OrtFilter', { + extend: 'Ext.window.Window', + alias: 'widget.ortfilterwindow', + +// layout: 'vbox', + layout: { + type: 'vbox', + align: 'left' + }, + width: 400, + resizable: false, + shadow: false, + alwaysOnTop: true, + + initComponent: function() { + var me = this; + var i18n = Lada.getApplication().bundle; + + me.items = [{ + name: 'nohits', + html: 'keine Treffer', + hidden: true, + width: '100%', + minHeight: 30 + }, { + xtype: 'grid', + name: 'messpunkte', + hideHeaders: true, + title: i18n.getMsg('orte'), + minHeight: 30, + maxHeight: 100, + width: '100%', + columns: [{ + dataIndex: 'ortId' + }, { + dataIndex: 'kurztext', + flex: 1 + }, { + dataIndex: 'gemId' + }] + }, { + xtype: 'grid', + name: 'verwaltungseinheiten', + hideHeaders: true, + title: i18n.getMsg('verwaltungseinheit'), + minHeight: 30, + maxHeight: 100, + width: '100%', + columns: [{ + dataIndex: 'id', + flex: 1, + renderer: function(value, meta, record) { + return value + ' - ' + record.get('bezeichnung'); + } + }] + }, { + xtype: 'grid', + name: 'staaten', + hideHeaders: true, + title: i18n.getMsg('staaten'), + minHeight: 30, + maxHeight: 100, + width: '100%', + columns: [{ + dataIndex: 'id', + flex: 1, + renderer: function(value, meta, record) { + return record.get('staatIso') + ' - ' + record.get('staat'); + } + }] + }]; + + me.callParent(arguments); + }, + + updateGrids: function(orte, verwaltungseinheiten, staaten) { + var mp = this.down('grid[name=messpunkte]') + var ve = this.down('grid[name=verwaltungseinheiten]'); + var st = this.down('grid[name=staaten]'); + var nohits = this.down('panel[name=nohits]'); + if (orte.count() > 0) { + mp.reconfigure(orte); + mp.show(); + nohits.hide(); + } + else { + mp.hide(); + } + if(verwaltungseinheiten.count() > 0) { + ve.reconfigure(verwaltungseinheiten) + ve.show(); + nohits.hide(); + } + else { + ve.hide(); + } + if (staaten.count() > 0) { + st.reconfigure(staaten) + st.show(); + nohits.hide(); + } + else { + st.hide(); + } + if (orte.count() === 0 && + verwaltungseinheiten.count() === 0 && + staaten.count() === 0 + ) { + nohits.show(); + } + }, + + reposition: function(x, y) { + var height = this.getHeight(); + this.setX(x); + this.setY(y - height); + } +}); diff -r 8b21a3fa6e1f -r e317ba349204 app/view/window/Ortszuordnung.js --- a/app/view/window/Ortszuordnung.js Thu Jan 26 17:33:18 2017 +0100 +++ b/app/view/window/Ortszuordnung.js Thu Jan 26 17:33:56 2017 +0100 @@ -119,7 +119,9 @@ }, items: [{ xtype: 'textfield', + name: 'search', labelWidth: 50, + enableKeyEvents: true, fieldLabel: i18n.getMsg('ortszuordnung.ortsuche'), }, '->', { text: i18n.getMsg('orte.new'),