comparison 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
comparison
equal deleted inserted replaced
1283:9d298c82575f 1284:faecbb446a04
12 Ext.define('Lada.controller.grid.Ortszuordnung', { 12 Ext.define('Lada.controller.grid.Ortszuordnung', {
13 extend: 'Ext.app.Controller', 13 extend: 'Ext.app.Controller',
14 14
15 requires: [ 15 requires: [
16 'Lada.view.window.Ortszuordnung', 16 'Lada.view.window.Ortszuordnung',
17 'Lada.view.form.Ortserstellung' 17 'Lada.view.window.Ortserstellung'
18 ], 18 ],
19 19
20 /** 20 /**
21 * Inhitialize the controller 21 * Inhitialize the controller
22 * It has 3 listeners 22 * It has 3 listeners
117 117
118 /** 118 /**
119 * Opens the form for a new Messpunkt 119 * Opens the form for a new Messpunkt
120 */ 120 */
121 createort: function() { 121 createort: function() {
122 Ext.create('Lada.view.form.Ortserstellung').show(); 122 Ext.create('Lada.view.window.Ortserstellung',{
123 parentWindow: button.up('ortszuordnungwindow')
124 }).show();
123 }, 125 },
124 126
125 /** 127 /**
126 * 128 *
127 * Opens the form for a new Messpunkt, with prefilled coordinates. 129 * Creates an event listener for a map click
128 * TODO Not functional yet
129 */ 130 */
130 frommap: function(button) { 131 frommap: function(button) {
131 var map = button.up('ortszuordnungwindow').down('map'); 132 var map = button.up('ortszuordnungwindow').down('map');
132 // map.getClick(); 133 var me = this;
133 //TODO: wait for click return 134 map.map.events.register('click', button, me.newOrtfromMapClick);
134 Ext.create('Lada.view.form.Ortserstellung', { 135 // TODO visual feedback that map click is active.
135 presets: { 136 // TODO Deactivate event listener if button is destroyed
136 kda_id: 4,
137 koord_x_extern: 35000000, //TODO dummy values
138 koord_y_extern: 1000000
139 }
140 }).show();
141 }, 137 },
142 138
143 /** 139 /**
144 * Opens the form for a new Messpunkt, with all values prefilled from the currently 140 * Opens the form for a new Messpunkt, with all values prefilled from the currently
145 * selected item 141 * selected item
146 */ 142 */
147 cloneort: function(button) { 143 cloneort: function(button) {
148 var grid = button.up('ortszuordnungwindow').down('ortstammdatengrid').getView(); 144 var grid = button.up('ortszuordnungwindow').down('ortstammdatengrid').getView();
149 var selected = grid.getSelectionModel().getSelection()[0]; 145 var selected = grid.getSelectionModel().getSelection()[0];
150 Ext.create('Lada.view.form.Ortserstellung', { 146 Ext.create('Lada.view.window.Ortserstellung', {
151 presets: selected.data 147 record: Ext.create('Lada.model.Ort', selected.data),
148 parentWindow: button.up('ortszuordnungwindow')
149 }).show();
150 },
151
152 /**
153 * Gets the clicked map's coordinates and opens a new Messpunkt window with coordinates prefilled
154 */
155 newOrtfromMapClick: function(evt) {
156 var me = this; //this = button(action:frommap)
157 var map = this.up('ortszuordnungwindow').down('map').map;
158 var lonlat = map.getLonLatFromViewPortPx(evt.xy).transform(new OpenLayers.Projection('EPSG:3857'),
159 new OpenLayers.Projection('EPSG:4326'));
160 var controller = Lada.app.getController('Lada.controller.grid.Ortszuordnung');
161 map.events.unregister('click', this, controller.newOrtfromMapClick);
162 Ext.create('Lada.view.window.Ortserstellung', {
163 record: Ext.create('Lada.model.Ort',{
164 koordXExtern: lonlat.lon,
165 koordYExtern: lonlat.lat,
166 kdaId : 4
167 }),
168 parentWindow: this.up('ortszuordnungwindow')
152 }).show(); 169 }).show();
153 } 170 }
154 }); 171 });

http://lada.wald.intevation.org