comparison app/controller/grid/Ortszuordnung.js @ 1361:5c2d6812d85a

Merge behaviour of Stammdaten panel and ortszuordnungs grid according to the recent changes in Ortszuordnung and Ortserstellung.
author Maximilian Krambach <mkrambach@intevation.de>
date Tue, 07 Feb 2017 19:50:36 +0100
parents 195c5d9b234b
children e98ec562764f
comparison
equal deleted inserted replaced
1360:d1dce50fa9a6 1361:5c2d6812d85a
152 parentWindow: button.up('ortszuordnungwindow') 152 parentWindow: button.up('ortszuordnungwindow')
153 }).show(); 153 }).show();
154 }, 154 },
155 155
156 /** 156 /**
157 * 157 * Creates a new Ortrecord from map coordinates
158 * Creates an event listener for a map click
159 */ 158 */
160 frommap: function(button) { 159 frommap: function(button) {
161 var map = button.up('ortszuordnungwindow').down('map'); 160 var map = button.up('ortszuordnungwindow').down('map');
162 map.getEl().setStyle('cursor', 'crosshair'); 161 var record = Ext.create('Lada.model.Ort');
163 var me = this; 162 map.activateDraw(record);
164 map.map.events.register('click', button, me.newOrtfromMapClick);
165 // TODO Deactivate event listener if button is destroyed
166 }, 163 },
167 164
168 /** 165 /**
169 * Opens the form for a new Messpunkt, with all values prefilled from the currently 166 * Opens the form for a new Messpunkt, with all values prefilled from the currently
170 * selected item 167 * selected item
176 newRecord.set('ortId', null); 173 newRecord.set('ortId', null);
177 newRecord.set('id', null); 174 newRecord.set('id', null);
178 Ext.create('Lada.view.window.Ortserstellung', { 175 Ext.create('Lada.view.window.Ortserstellung', {
179 record: newRecord, 176 record: newRecord,
180 parentWindow: button.up('ortszuordnungwindow') 177 parentWindow: button.up('ortszuordnungwindow')
181 }).show();
182 },
183
184 /**
185 * Gets the clicked map's coordinates and opens a new Messpunkt window with coordinates prefilled
186 */
187 newOrtfromMapClick: function(evt) {
188 var me = this; //this = button(action:frommap)
189 var map = this.up('ortszuordnungwindow').down('map').map;
190 this.up('ortszuordnungwindow').down('map').getEl().setStyle('cursor', 'auto');
191 var lonlat = map.getLonLatFromViewPortPx(evt.xy).transform(new OpenLayers.Projection('EPSG:3857'),
192 new OpenLayers.Projection('EPSG:4326'));
193 var controller = Lada.app.getController('Lada.controller.grid.Ortszuordnung');
194 map.events.unregister('click', this, controller.newOrtfromMapClick);
195 Ext.create('Lada.view.window.Ortserstellung', {
196 record: Ext.create('Lada.model.Ort',{
197 koordXExtern: lonlat.lon,
198 koordYExtern: lonlat.lat,
199 kdaId : 4,
200 ortTyp: 1
201 }),
202 parentWindow: this.up('ortszuordnungwindow')
203 }).show(); 178 }).show();
204 }, 179 },
205 180
206 /** 181 /**
207 * Search triggered by textfield key event. 182 * Search triggered by textfield key event.

http://lada.wald.intevation.org