comparison app/view/window/Ortszuordnung.js @ 1302:322da3ad0c0b

Load current Ort into ortszuordnungswindow even if netzbetreiber doesn't match
author Maximilian Krambach <mkrambach@intevation.de>
date Thu, 02 Feb 2017 13:33:38 +0100
parents c1b7db04b39c
children 996607be4752
comparison
equal deleted inserted replaced
1301:f87bac93cd3d 1302:322da3ad0c0b
183 if (!this.record.get('letzteAenderung')) { 183 if (!this.record.get('letzteAenderung')) {
184 this.record.data.letzteAenderung = new Date(); 184 this.record.data.letzteAenderung = new Date();
185 } 185 }
186 } 186 }
187 this.down('ortszuordnungform').setRecord(this.record); 187 this.down('ortszuordnungform').setRecord(this.record);
188 var osg = this.down('ortstammdatengrid');
188 var map = this.down('map'); 189 var map = this.down('map');
189 var osg = this.down('ortstammdatengrid'); 190 osg.setLoading(true);
190 this.ortstore = Ext.create('Lada.store.Orte', { 191 map.setLoading(true);
191 defaultPageSize: 0, 192 this.ortstore = Ext.data.StoreManager.get('orte');
192 autoLoad: false, 193 var ortId;
193 listeners: { 194 if (this.messprogramm) {
194 beforeload: { 195 ortId = this.record.get('ort');
195 fn: function() { 196 } else {
196 osg.setLoading(true); 197 ortId = this.record.get('ortId');
197 map.setLoading(true); 198 }
199 if (ortId !== undefined && !this.ortstore.findRecord('id', ortId)) {
200 var record = Ext.create('Lada.model.Ort');
201 record.set('id', ortId);
202 this.ortstore.add(record);
203 Lada.model.Ort.load(ortId, {
204 success: function(rec) {
205 record.beginEdit();
206 for (key in rec.getData()) {
207 record.set(key, rec.getData()[key]);
198 } 208 }
199 }, 209 record.endEdit();
200 load: { 210 me.onStoreLoaded();
201 fn: function() {
202 osg.setLoading(false);
203 map.setLoading(false);
204 osg.setStore(me.ortstore);
205 map.addLocations(me.ortstore);
206 map.featureLayer.setVisibility(false);
207 map.selectedFeatureLayer = new OpenLayers.Layer.Vector(
208 'gewählter Messpunkt', {
209 styleMap: new OpenLayers.StyleMap({
210 externalGraphic: 'resources/lib/OpenLayers/img/marker-blue.png',
211 pointRadius: 12,
212 label: '${bez}',
213 labelAlign: 'rt',
214 fontColor: 'blue',
215 fontWeight: 'bold',
216 }),
217 displayInLayerSwitcher: false,
218 projection: new OpenLayers.Projection('EPSG:3857')
219 });
220 map.map.addLayer(map.selectedFeatureLayer);
221 map.selectedFeatureLayer.setZIndex(499);
222 var ortId = me.messprogramm? me.record.get('ort') : me.record.get('ortId');
223 if (ortId){
224 var feat = map.featureLayer.getFeaturesByAttribute('id', ortId);
225 var ortrecord = this.findRecord('id', ortId);
226 osg.selectOrt(map, feat);
227 map.selectFeature(this.model, ortrecord);
228 me.down('ortszuordnungform').setOrt(null,ortrecord);
229 }
230 }
231 } 211 }
232 } 212 });
233 }); 213 } else {
234 this.ortstore.load(); 214 me.onStoreLoaded();
215 }
235 map.addListener('featureselected', osg.selectOrt, osg); 216 map.addListener('featureselected', osg.selectOrt, osg);
236 osg.addListener('select', map.selectFeature, map); 217 osg.addListener('select', map.selectFeature, map);
237 osg.addListener('select', me.activateCloneButton, me); 218 osg.addListener('select', me.activateCloneButton, me);
238 }, 219 },
239 220
264 }, 245 },
265 246
266 activateCloneButton: function() { 247 activateCloneButton: function() {
267 var toolbar = this.down('panel[name=ortgrid]').getDockedItems()[0]; 248 var toolbar = this.down('panel[name=ortgrid]').getDockedItems()[0];
268 toolbar.down('button[action=clone]').enable(); 249 toolbar.down('button[action=clone]').enable();
250 },
251
252 /**
253 * childs will be populated with store entries after all entries are loaded
254 * from all sources
255 */
256 onStoreLoaded: function() {
257 var map = this.down('map');
258 var osg = this.down('ortstammdatengrid');
259 osg.setStore(this.ortstore);
260 map.addLocations(this.ortstore);
261 map.featureLayer.setVisibility(false);
262 map.selectedFeatureLayer = new OpenLayers.Layer.Vector(
263 'gewählter Messpunkt', {
264 styleMap: new OpenLayers.StyleMap({
265 externalGraphic: 'resources/lib/OpenLayers/img/marker-blue.png',
266 pointRadius: 12,
267 label: '${bez}',
268 labelAlign: 'rt',
269 fontColor: 'blue',
270 fontWeight: 'bold',
271 }),
272 displayInLayerSwitcher: false,
273 projection: new OpenLayers.Projection('EPSG:3857')
274 });
275 map.map.addLayer(map.selectedFeatureLayer);
276 map.selectedFeatureLayer.setZIndex(499);
277 var ortId;
278 if (this.messprogramm) {
279 ortId = this.record.get('ort');
280 } else {
281 ortId = this.record.get('ortId');
282 }
283 if (ortId){
284 var feat = map.featureLayer.getFeaturesByAttribute('id', ortId);
285 var ortrecord = this.ortstore.findRecord('id', ortId);
286 osg.selectOrt(map, feat);
287 map.selectFeature(this.model, ortrecord);
288 this.down('ortszuordnungform').setOrt(null,ortrecord);
289 }
290 osg.setLoading(false);
291 map.setLoading(false);
269 } 292 }
270 }); 293 });
271 294

http://lada.wald.intevation.org