comparison app/controller/grid/Ortszuordnung.js @ 1288:08085b7d1d0b

Ortszuordnung: Search, new orte, display and validity check
author Maximilian Krambach <mkrambach@intevation.de>
date Fri, 27 Jan 2017 13:25:14 +0100
parents e317ba349204
children bfdc00c24baf
comparison
equal deleted inserted replaced
1287:e317ba349204 1288:08085b7d1d0b
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 'Lada.view.window.OrtFilter' 18 'Lada.view.window.OrtFilter'
19 ], 19 ],
20 20
21 resultPanel: null, 21 resultPanel: null,
22 searchField: null, 22 searchField: null,
132 }, 132 },
133 133
134 /** 134 /**
135 * Opens the form for a new Messpunkt 135 * Opens the form for a new Messpunkt
136 */ 136 */
137 createort: function() { 137 createort: function(button) {
138 Ext.create('Lada.view.form.Ortserstellung').show(); 138 Ext.create('Lada.view.window.Ortserstellung',{
139 parentWindow: button.up('ortszuordnungwindow')
140 }).show();
139 }, 141 },
140 142
141 /** 143 /**
142 * 144 *
143 * Opens the form for a new Messpunkt, with prefilled coordinates. 145 * Creates an event listener for a map click
144 * TODO Not functional yet
145 */ 146 */
146 frommap: function(button) { 147 frommap: function(button) {
147 var map = button.up('ortszuordnungwindow').down('map'); 148 var map = button.up('ortszuordnungwindow').down('map');
148 // map.getClick(); 149 var me = this;
149 //TODO: wait for click return 150 map.map.events.register('click', button, me.newOrtfromMapClick);
150 Ext.create('Lada.view.form.Ortserstellung', { 151 // TODO visual feedback that map click is active.
151 presets: { 152 // TODO Deactivate event listener if button is destroyed
152 kda_id: 4,
153 koord_x_extern: 35000000, //TODO dummy values
154 koord_y_extern: 1000000
155 }
156 }).show();
157 }, 153 },
158 154
159 /** 155 /**
160 * Opens the form for a new Messpunkt, with all values prefilled from the currently 156 * Opens the form for a new Messpunkt, with all values prefilled from the currently
161 * selected item 157 * selected item
162 */ 158 */
163 cloneort: function(button) { 159 cloneort: function(button) {
164 var grid = button.up('ortszuordnungwindow').down('ortstammdatengrid').getView(); 160 var grid = button.up('ortszuordnungwindow').down('ortstammdatengrid').getView();
165 var selected = grid.getSelectionModel().getSelection()[0]; 161 var selected = grid.getSelectionModel().getSelection()[0];
166 Ext.create('Lada.view.form.Ortserstellung', { 162 Ext.create('Lada.view.window.Ortserstellung', {
167 presets: selected.data 163 record: Ext.create('Lada.model.Ort', selected.data),
164 parentWindow: button.up('ortszuordnungwindow')
165 }).show();
166 },
167
168 /**
169 * Gets the clicked map's coordinates and opens a new Messpunkt window with coordinates prefilled
170 */
171 newOrtfromMapClick: function(evt) {
172 var me = this; //this = button(action:frommap)
173 var map = this.up('ortszuordnungwindow').down('map').map;
174 var lonlat = map.getLonLatFromViewPortPx(evt.xy).transform(new OpenLayers.Projection('EPSG:3857'),
175 new OpenLayers.Projection('EPSG:4326'));
176 var controller = Lada.app.getController('Lada.controller.grid.Ortszuordnung');
177 map.events.unregister('click', this, controller.newOrtfromMapClick);
178 Ext.create('Lada.view.window.Ortserstellung', {
179 record: Ext.create('Lada.model.Ort',{
180 koordXExtern: lonlat.lon,
181 koordYExtern: lonlat.lat,
182 kdaId : 4
183 }),
184 parentWindow: this.up('ortszuordnungwindow')
168 }).show(); 185 }).show();
169 }, 186 },
170 187
171 /** 188 /**
172 * Search triggered by textfield key event. 189 * Search triggered by textfield key event.
237 win.hide(); 254 win.hide();
238 this.searchField.reset(); 255 this.searchField.reset();
239 var grid = this.searchField.up('panel').down('ortstammdatengrid'); 256 var grid = this.searchField.up('panel').down('ortstammdatengrid');
240 grid.getSelectionModel().select(record); 257 grid.getSelectionModel().select(record);
241 grid.getView().focusRow(record); 258 grid.getView().focusRow(record);
242 console.log(record);
243 }, 259 },
244 260
245 selectedVerwaltungseinheit: function(grid, record) { 261 selectedVerwaltungseinheit: function(grid, record) {
246 var win = grid.up('window'); 262 var win = grid.up('window');
247 win.hide(); 263 win.hide();
248 this.searchField.reset(); 264 this.searchField.reset();
249 console.log(record); 265 Ext.create('Lada.view.window.Ortserstellung', {
266 record: Ext.create('Lada.model.Ort', record.data),
267 parentWindow: grid.up('ortszuordnungwindow')
268 }).show();
250 }, 269 },
251 270
252 selectedStaat: function(grid, record) { 271 selectedStaat: function(grid, record) {
253 var win = grid.up('window'); 272 var win = grid.up('window');
273 console.log(grid.up('ortszuordnungwindow'));
254 win.hide(); 274 win.hide();
275 Ext.create('Lada.view.window.Ortserstellung', {
276 record: Ext.create('Lada.model.Ort', record.data),
277 parentWindow: grid.up('ortszuordnungwindow')
278 }).show();
255 this.searchField.reset(); 279 this.searchField.reset();
256 console.log(record);
257 } 280 }
258 }); 281 });

http://lada.wald.intevation.org