Mercurial > lada > lada-client
diff app/controller/grid/Ortszuordnung.js @ 1284:faecbb446a04
Ortserstellung: new Messpunkt from map, clone or form
functional, still needs error handling and layout
author | Maximilian Krambach <mkrambach@intevation.de> |
---|---|
date | Tue, 24 Jan 2017 12:58:26 +0100 |
parents | 291df0037835 |
children | e317ba349204 |
line wrap: on
line diff
--- a/app/controller/grid/Ortszuordnung.js Wed Jan 18 16:03:40 2017 +0100 +++ b/app/controller/grid/Ortszuordnung.js Tue Jan 24 12:58:26 2017 +0100 @@ -14,7 +14,7 @@ requires: [ 'Lada.view.window.Ortszuordnung', - 'Lada.view.form.Ortserstellung' + 'Lada.view.window.Ortserstellung' ], /** @@ -119,25 +119,21 @@ * Opens the form for a new Messpunkt */ createort: function() { - Ext.create('Lada.view.form.Ortserstellung').show(); + Ext.create('Lada.view.window.Ortserstellung',{ + parentWindow: button.up('ortszuordnungwindow') + }).show(); }, /** * - * Opens the form for a new Messpunkt, with prefilled coordinates. - * TODO Not functional yet + * Creates an event listener for a map click */ frommap: function(button) { var map = button.up('ortszuordnungwindow').down('map'); - // 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(); + 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 }, /** @@ -147,8 +143,29 @@ cloneort: function(button) { var grid = button.up('ortszuordnungwindow').down('ortstammdatengrid').getView(); var selected = grid.getSelectionModel().getSelection()[0]; - Ext.create('Lada.view.form.Ortserstellung', { - presets: selected.data + Ext.create('Lada.view.window.Ortserstellung', { + record: Ext.create('Lada.model.Ort', selected.data), + parentWindow: button.up('ortszuordnungwindow') + }).show(); + }, + + /** + * Gets the clicked map's coordinates and opens a new Messpunkt window with coordinates prefilled + */ + 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(); } });