[Lada-commits] [PATCH] Load current Ort into ortszuordnungswindow even if netzbetreiber doesn't match
Wald Commits
scm-commit at wald.intevation.org
Thu Feb 2 13:33:51 CET 2017
# HG changeset patch
# User Maximilian Krambach <mkrambach at intevation.de>
# Date 1486038818 -3600
# Node ID 322da3ad0c0b71548469001a01c7696cd459009f
# Parent f87bac93cd3d3c2790b604e000cec7fa23f530b7
Load current Ort into ortszuordnungswindow even if netzbetreiber doesn't match
diff -r f87bac93cd3d -r 322da3ad0c0b app/view/window/Ortszuordnung.js
--- a/app/view/window/Ortszuordnung.js Thu Feb 02 13:11:11 2017 +0100
+++ b/app/view/window/Ortszuordnung.js Thu Feb 02 13:33:38 2017 +0100
@@ -185,53 +185,34 @@
}
}
this.down('ortszuordnungform').setRecord(this.record);
+ var osg = this.down('ortstammdatengrid');
var map = this.down('map');
- var osg = this.down('ortstammdatengrid');
- this.ortstore = Ext.create('Lada.store.Orte', {
- defaultPageSize: 0,
- autoLoad: false,
- listeners: {
- beforeload: {
- fn: function() {
- osg.setLoading(true);
- map.setLoading(true);
+ osg.setLoading(true);
+ map.setLoading(true);
+ this.ortstore = Ext.data.StoreManager.get('orte');
+ var ortId;
+ if (this.messprogramm) {
+ ortId = this.record.get('ort');
+ } else {
+ ortId = this.record.get('ortId');
+ }
+ if (ortId !== undefined && !this.ortstore.findRecord('id', ortId)) {
+ var record = Ext.create('Lada.model.Ort');
+ record.set('id', ortId);
+ this.ortstore.add(record);
+ Lada.model.Ort.load(ortId, {
+ success: function(rec) {
+ record.beginEdit();
+ for (key in rec.getData()) {
+ record.set(key, rec.getData()[key]);
}
- },
- load: {
- fn: function() {
- osg.setLoading(false);
- map.setLoading(false);
- osg.setStore(me.ortstore);
- map.addLocations(me.ortstore);
- map.featureLayer.setVisibility(false);
- map.selectedFeatureLayer = new OpenLayers.Layer.Vector(
- 'gewählter Messpunkt', {
- styleMap: new OpenLayers.StyleMap({
- externalGraphic: 'resources/lib/OpenLayers/img/marker-blue.png',
- pointRadius: 12,
- label: '${bez}',
- labelAlign: 'rt',
- fontColor: 'blue',
- fontWeight: 'bold',
- }),
- displayInLayerSwitcher: false,
- projection: new OpenLayers.Projection('EPSG:3857')
- });
- map.map.addLayer(map.selectedFeatureLayer);
- map.selectedFeatureLayer.setZIndex(499);
- var ortId = me.messprogramm? me.record.get('ort') : me.record.get('ortId');
- if (ortId){
- var feat = map.featureLayer.getFeaturesByAttribute('id', ortId);
- var ortrecord = this.findRecord('id', ortId);
- osg.selectOrt(map, feat);
- map.selectFeature(this.model, ortrecord);
- me.down('ortszuordnungform').setOrt(null,ortrecord);
- }
- }
+ record.endEdit();
+ me.onStoreLoaded();
}
- }
- });
- this.ortstore.load();
+ });
+ } else {
+ me.onStoreLoaded();
+ }
map.addListener('featureselected', osg.selectOrt, osg);
osg.addListener('select', map.selectFeature, map);
osg.addListener('select', me.activateCloneButton, me);
@@ -266,6 +247,48 @@
activateCloneButton: function() {
var toolbar = this.down('panel[name=ortgrid]').getDockedItems()[0];
toolbar.down('button[action=clone]').enable();
+ },
+
+ /**
+ * childs will be populated with store entries after all entries are loaded
+ * from all sources
+ */
+ onStoreLoaded: function() {
+ var map = this.down('map');
+ var osg = this.down('ortstammdatengrid');
+ osg.setStore(this.ortstore);
+ map.addLocations(this.ortstore);
+ map.featureLayer.setVisibility(false);
+ map.selectedFeatureLayer = new OpenLayers.Layer.Vector(
+ 'gewählter Messpunkt', {
+ styleMap: new OpenLayers.StyleMap({
+ externalGraphic: 'resources/lib/OpenLayers/img/marker-blue.png',
+ pointRadius: 12,
+ label: '${bez}',
+ labelAlign: 'rt',
+ fontColor: 'blue',
+ fontWeight: 'bold',
+ }),
+ displayInLayerSwitcher: false,
+ projection: new OpenLayers.Projection('EPSG:3857')
+ });
+ map.map.addLayer(map.selectedFeatureLayer);
+ map.selectedFeatureLayer.setZIndex(499);
+ var ortId;
+ if (this.messprogramm) {
+ ortId = this.record.get('ort');
+ } else {
+ ortId = this.record.get('ortId');
+ }
+ if (ortId){
+ var feat = map.featureLayer.getFeaturesByAttribute('id', ortId);
+ var ortrecord = this.ortstore.findRecord('id', ortId);
+ osg.selectOrt(map, feat);
+ map.selectFeature(this.model, ortrecord);
+ this.down('ortszuordnungform').setOrt(null,ortrecord);
+ }
+ osg.setLoading(false);
+ map.setLoading(false);
}
});
More information about the Lada-commits
mailing list