Mercurial > lada > lada-client
comparison app/controller/grid/Ortszuordnung.js @ 1287:e317ba349204
Added search for orte, verwaltungseinheiten and staaten.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 26 Jan 2017 17:33:56 +0100 |
parents | faecbb446a04 |
children | 08085b7d1d0b |
comparison
equal
deleted
inserted
replaced
1286:8b21a3fa6e1f | 1287:e317ba349204 |
---|---|
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.window.Ortserstellung' | 17 'Lada.view.form.Ortserstellung', |
18 'Lada.view.window.OrtFilter' | |
18 ], | 19 ], |
20 | |
21 resultPanel: null, | |
22 searchField: null, | |
19 | 23 |
20 /** | 24 /** |
21 * Inhitialize the controller | 25 * Inhitialize the controller |
22 * It has 3 listeners | 26 * It has 3 listeners |
23 */ | 27 */ |
38 'ortszuordnungwindow toolbar button[action=frommap]':{ | 42 'ortszuordnungwindow toolbar button[action=frommap]':{ |
39 click: this.frommap | 43 click: this.frommap |
40 }, | 44 }, |
41 'ortszuordnungwindow toolbar button[action=clone]':{ | 45 'ortszuordnungwindow toolbar button[action=clone]':{ |
42 click: this.cloneort | 46 click: this.cloneort |
47 }, | |
48 'ortszuordnungwindow toolbar textfield[name=search]': { | |
49 keyup: this.search | |
50 }, | |
51 'ortfilterwindow grid[name=messpunkte]': { | |
52 itemdblclick: this.selectedMesspunkt | |
53 }, | |
54 'ortfilterwindow grid[name=verwaltungseinheiten]': { | |
55 itemdblclick: this.selectedVerwaltungseinheit | |
56 }, | |
57 'ortfilterwindow grid[name=staaten]': { | |
58 itemdblclick: this.selectedStaat | |
43 } | 59 } |
44 }); | 60 }); |
45 }, | 61 }, |
46 | 62 |
47 /** | 63 /** |
117 | 133 |
118 /** | 134 /** |
119 * Opens the form for a new Messpunkt | 135 * Opens the form for a new Messpunkt |
120 */ | 136 */ |
121 createort: function() { | 137 createort: function() { |
122 Ext.create('Lada.view.window.Ortserstellung',{ | 138 Ext.create('Lada.view.form.Ortserstellung').show(); |
123 parentWindow: button.up('ortszuordnungwindow') | |
124 }).show(); | |
125 }, | 139 }, |
126 | 140 |
127 /** | 141 /** |
128 * | 142 * |
129 * Creates an event listener for a map click | 143 * Opens the form for a new Messpunkt, with prefilled coordinates. |
144 * TODO Not functional yet | |
130 */ | 145 */ |
131 frommap: function(button) { | 146 frommap: function(button) { |
132 var map = button.up('ortszuordnungwindow').down('map'); | 147 var map = button.up('ortszuordnungwindow').down('map'); |
133 var me = this; | 148 // map.getClick(); |
134 map.map.events.register('click', button, me.newOrtfromMapClick); | 149 //TODO: wait for click return |
135 // TODO visual feedback that map click is active. | 150 Ext.create('Lada.view.form.Ortserstellung', { |
136 // TODO Deactivate event listener if button is destroyed | 151 presets: { |
152 kda_id: 4, | |
153 koord_x_extern: 35000000, //TODO dummy values | |
154 koord_y_extern: 1000000 | |
155 } | |
156 }).show(); | |
137 }, | 157 }, |
138 | 158 |
139 /** | 159 /** |
140 * Opens the form for a new Messpunkt, with all values prefilled from the currently | 160 * Opens the form for a new Messpunkt, with all values prefilled from the currently |
141 * selected item | 161 * selected item |
142 */ | 162 */ |
143 cloneort: function(button) { | 163 cloneort: function(button) { |
144 var grid = button.up('ortszuordnungwindow').down('ortstammdatengrid').getView(); | 164 var grid = button.up('ortszuordnungwindow').down('ortstammdatengrid').getView(); |
145 var selected = grid.getSelectionModel().getSelection()[0]; | 165 var selected = grid.getSelectionModel().getSelection()[0]; |
146 Ext.create('Lada.view.window.Ortserstellung', { | 166 Ext.create('Lada.view.form.Ortserstellung', { |
147 record: Ext.create('Lada.model.Ort', selected.data), | 167 presets: selected.data |
148 parentWindow: button.up('ortszuordnungwindow') | |
149 }).show(); | 168 }).show(); |
150 }, | 169 }, |
151 | 170 |
152 /** | 171 /** |
153 * Gets the clicked map's coordinates and opens a new Messpunkt window with coordinates prefilled | 172 * Search triggered by textfield key event. |
154 */ | 173 */ |
155 newOrtfromMapClick: function(evt) { | 174 search: function(field, evt, opts) { |
156 var me = this; //this = button(action:frommap) | 175 this.searchField = field; |
157 var map = this.up('ortszuordnungwindow').down('map').map; | 176 if ((evt.getKey() == 13 || evt.getKey() == 8) && field.getValue() && field.getValue().length > 0) { |
158 var lonlat = map.getLonLatFromViewPortPx(evt.xy).transform(new OpenLayers.Projection('EPSG:3857'), | 177 this.execSearch(field, field.getValue()); |
159 new OpenLayers.Projection('EPSG:4326')); | 178 } |
160 var controller = Lada.app.getController('Lada.controller.grid.Ortszuordnung'); | 179 if (field.getValue().length === 0) { |
161 map.events.unregister('click', this, controller.newOrtfromMapClick); | 180 this.resultPanel.hide(); |
162 Ext.create('Lada.view.window.Ortserstellung', { | 181 return; |
163 record: Ext.create('Lada.model.Ort',{ | 182 } |
164 koordXExtern: lonlat.lon, | 183 if (field.getValue().length < 3) { |
165 koordYExtern: lonlat.lat, | 184 return; |
166 kdaId : 4 | 185 } |
167 }), | 186 this.execSearch(field, field.getValue()); |
168 parentWindow: this.up('ortszuordnungwindow') | 187 }, |
169 }).show(); | 188 |
189 /* | |
190 * Execute search in stores (ort, verwaltungseinheit and staat) and | |
191 * display the resultset. | |
192 */ | |
193 execSearch: function(field, filter) { | |
194 // Filter stores | |
195 var messpunkte = Ext.data.StoreManager.get('orte'); | |
196 var verwaltungseinheiten = Ext.data.StoreManager.get('verwaltungseinheiten'); | |
197 var staaten = Ext.data.StoreManager.get('staaten'); | |
198 messpunkte.clearFilter(true); | |
199 verwaltungseinheiten.clearFilter(true); | |
200 staaten.clearFilter(true); | |
201 messpunkte.filter({filterFn: function(item) { | |
202 if (item.get('ortId').indexOf(filter) > -1) { | |
203 return true; | |
204 } | |
205 if (item.get('kurztext').indexOf(filter) > -1) { | |
206 return true; | |
207 } | |
208 if (item.get('langtext').indexOf(filter) > -1) { | |
209 return true; | |
210 } | |
211 if (item.get('berichtstext') && | |
212 item.get('berichtstext').indexOf(filter) > -1) { | |
213 return true; | |
214 } | |
215 if (item.get('gemId').indexOf(filter) > -1) { | |
216 return true; | |
217 } | |
218 }}); | |
219 verwaltungseinheiten.filter('bezeichnung', filter); | |
220 staaten.filter('staat', filter); | |
221 | |
222 if (!this.resultPanel) { | |
223 this.resultPanel = Ext.create('Lada.view.window.OrtFilter', { | |
224 x: 500, | |
225 y: 500, | |
226 alwaysOnTop: true | |
227 }); | |
228 } | |
229 this.resultPanel.show(); | |
230 this.resultPanel.updateGrids(messpunkte, verwaltungseinheiten, staaten); | |
231 this.resultPanel.reposition(field.getX() + field.getLabelWidth(), field.getY()); | |
232 field.focus(); | |
233 }, | |
234 | |
235 selectedMesspunkt: function(grid, record) { | |
236 var win = grid.up('window'); | |
237 win.hide(); | |
238 this.searchField.reset(); | |
239 var grid = this.searchField.up('panel').down('ortstammdatengrid'); | |
240 grid.getSelectionModel().select(record); | |
241 grid.getView().focusRow(record); | |
242 console.log(record); | |
243 }, | |
244 | |
245 selectedVerwaltungseinheit: function(grid, record) { | |
246 var win = grid.up('window'); | |
247 win.hide(); | |
248 this.searchField.reset(); | |
249 console.log(record); | |
250 }, | |
251 | |
252 selectedStaat: function(grid, record) { | |
253 var win = grid.up('window'); | |
254 win.hide(); | |
255 this.searchField.reset(); | |
256 console.log(record); | |
170 } | 257 } |
171 }); | 258 }); |