diff app/view/window/OrtEdit.js @ 796:7267bae1d43f

made window-panel recyclable, fwd openlayers events to ext
author Dustin Demuth <dustin@intevation.de>
date Wed, 20 May 2015 14:19:12 +0200
parents 6bc05ba2f6b1
children e5f72fb491f4
line wrap: on
line diff
--- a/app/view/window/OrtEdit.js	Mon May 18 17:04:32 2015 +0200
+++ b/app/view/window/OrtEdit.js	Wed May 20 14:19:12 2015 +0200
@@ -6,8 +6,8 @@
  * the documentation coming with IMIS-Labordaten-Application for details.
  */
 
-/*
- * Window to edit a Messung
+/**
+ * Window to edit a Ort
  */
 Ext.define('Lada.view.window.OrtEdit', {
     extend: 'Ext.window.Window',
@@ -93,7 +93,10 @@
                 bodyStyle: {
                     background: '#fff'
                 },
-                name: 'map'
+                name: 'map',
+                listeners: { //A listener which listens to the mappanels featureselected event
+                    featureselected: this.selectedFeature
+                }
             }]
         }];
         this.callParent(arguments);
@@ -141,6 +144,39 @@
         });
     },
 
+    /**
+     * @private
+     * Override to display and update the map view in the panel.
+     */
+    afterRender: function(){
+        this.superclass.afterRender.apply(this, arguments);
+        var map = this.down('map');
+        if (this.record) {
+            map.selectFeature(this.record.get('ort'));
+        }
+        else {
+            map.map.zoomToMaxExtent();
+        }
+    },
+
+    /**
+     * This function is used by the MapPanel, when a Feature was selected
+     */
+    selectedFeature: function(context, args) {
+    var feature = args[0];
+        if (feature.attributes.id &&
+            feature.attributes.id !== '') {
+            var record = Ext.data.StoreManager.get('locations').getById(feature.attributes.id);
+            context.up('window').down('locationform').setRecord(record);
+            context.up('window').down('locationform').setReadOnly(true);
+            context.up('window').down('ortform').down('combobox').setValue(record.id);
+        }
+        else {
+            context.up('window').down('locationform').setRecord(this.locationRecord);
+            context.up('window').down('locationform').setReadOnly(false);
+        }
+    },
+
     setMessages: function(errors, warnings) {
         //todo this is a stub
     },

http://lada.wald.intevation.org