[Commits] r1727 - in sandbox/redlining/ux/FeatureEditing/ux/widgets: . form plugins
commits at geoext.org
commits at geoext.org
Tue Jan 12 21:17:47 CET 2010
Author: adube
Date: 2010-01-12 21:17:47 +0100 (Tue, 12 Jan 2010)
New Revision: 1727
Modified:
sandbox/redlining/ux/FeatureEditing/ux/widgets/FeatureEditingControler.js
sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeatureEditingPanel.js
sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeaturePanel.js
sandbox/redlining/ux/FeatureEditing/ux/widgets/form/RedLiningPanel.js
sandbox/redlining/ux/FeatureEditing/ux/widgets/plugins/ExportFeature.js
Log:
attributes auto-generation, auto-save support, feature attr. parsing
Modified: sandbox/redlining/ux/FeatureEditing/ux/widgets/FeatureEditingControler.js
===================================================================
--- sandbox/redlining/ux/FeatureEditing/ux/widgets/FeatureEditingControler.js 2010-01-12 19:12:42 UTC (rev 1726)
+++ sandbox/redlining/ux/FeatureEditing/ux/widgets/FeatureEditingControler.js 2010-01-12 20:17:47 UTC (rev 1727)
@@ -61,6 +61,12 @@
*/
activeLayer: null,
+ /** api: config[featurePanel]
+ * ``GeoExt.ux.form.FeaturePanel``
+ * A reference to the FeaturePanel object created
+ */
+ featurePanel: null,
+
/** private: method[constructor]
* Private constructor override.
*/
@@ -374,7 +380,7 @@
plugins: [new GeoExt.ux.ExportFeature()]
};
- var featurePanel = new GeoExt.ux.form.FeaturePanel(options);
+ this.featurePanel = new GeoExt.ux.form.FeaturePanel(options);
// display the popup
var popup = new GeoExt.Popup({
@@ -382,7 +388,7 @@
title: 'EditFeature',
controler: this,
layout: 'fit',
- items: [featurePanel]
+ items: [this.featurePanel]
});
feature.popup = popup;
popup.on({
@@ -426,10 +432,20 @@
onFeatureUnselect: function(event) {
var feature = (event.geometry) ? event : event.feature;
+ this.triggerAutoSave();
+
if(feature.popup){
feature.popup.close();
}
},
+ /** private: method[triggerAutoSave]
+ */
+ triggerAutoSave: function() {
+ if(this.autoSave) {
+ this.featurePanel.triggerAutoSave();
+ }
+ },
+
CLASS_NAME: "GeoExt.ux.FeatureEditingControler"
});
Modified: sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeatureEditingPanel.js
===================================================================
--- sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeatureEditingPanel.js 2010-01-12 19:12:42 UTC (rev 1726)
+++ sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeatureEditingPanel.js 2010-01-12 20:17:47 UTC (rev 1727)
@@ -111,7 +111,8 @@
initControler: function() {
if(!this.controler){
this.controler = new GeoExt.ux.FeatureEditingControler({
- map: this.map
+ map: this.map,
+ autoSave: this.autoSave
});
}
},
Modified: sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeaturePanel.js
===================================================================
--- sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeaturePanel.js 2010-01-12 19:12:42 UTC (rev 1726)
+++ sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeaturePanel.js 2010-01-12 20:17:47 UTC (rev 1727)
@@ -92,6 +92,12 @@
*/
deleteAction: null,
+ /** api: config[attributeFieldSetId]
+ * ``String``
+ * The id used when creating the FieldSet for the attribute fields.
+ */
+ attributeFieldSetId: "gx_featurepanel_attributefieldset_id",
+
/** private: method[initComponent]
*/
initComponent: function() {
@@ -99,9 +105,14 @@
this.initToolbar();
this.initForm();
+ this.on("afterrender", this.onAfterRender, this);
+
GeoExt.ux.form.FeaturePanel.superclass.initComponent.call(this);
},
+ /** private: method[initFeatures]
+ * :param features: ``Array(OpenLayers.Feature.Vector)``
+ */
initFeatures: function(features) {
if(features instanceof Array) {
this.features = features;
@@ -136,6 +147,7 @@
oItems = [];
oGroupItems = [];
oGroup = {
+ id: this.attributeFieldSetId,
xtype: 'fieldset',
title: 'Attributes',
layout: 'form',
@@ -147,7 +159,11 @@
};
for(var attribute in feature.attributes) {
- field = {'name': attribute, 'fieldLabel': attribute};
+ field = {
+ 'name': attribute,
+ 'fieldLabel': attribute,
+ 'id': attribute
+ };
oGroupItems.push(field);
}
@@ -172,7 +188,7 @@
this.deleteAction = action;
},
- /** private: method[deleteFeatures]
+ /** private: method[deleteFeatures]
* Called when the deleteAction is triggered (button pressed).
* Destroy all features from all layers.
*/
@@ -183,6 +199,8 @@
}
},
+ /** private: method[getActions]
+ */
getActions: function() {
var actions = [];
@@ -191,6 +209,88 @@
return actions;
},
+ /** private: method[triggerAutoSave]
+ */
+ triggerAutoSave: function() {
+ if(this.autoSave) {
+ this.save();
+ }
+ },
+
+ /** private: method[save]
+ */
+ save: function() {
+ var feature;
+
+ if(this.features.length != 1) {
+ return;
+ } else {
+ feature = this.features[0];
+ }
+
+ this.parseFormFieldsToFeatureAttributes(feature);
+ },
+
+ /** private: method[parseFeatureAttributesToFormFields]
+ * :param feature: ``OpenLayers.Feature.Vector``
+ * Copy each attribute values of a feature to its corresponding form field.
+ */
+ parseFeatureAttributesToFormFields: function(feature) {
+ var aoElements, nElements, fieldSet;
+
+ fieldSet = this.findById(this.attributeFieldSetId);
+ aoElements = fieldSet.items.items;
+ nElements = aoElements.length;
+
+ for (var i=0; i<nElements; i++){
+ var oElement = aoElements[i];
+ var szAttribute = oElement.getName();
+ var szValue = null;
+ if (oElement.initialConfig.isfid)
+ {
+ szValue = feature.fid;
+ }
+ else
+ {
+ szValue = feature.attributes[szAttribute];
+ }
+ oElement.setValue(szValue);
+ }
+ },
+
+ /** private: method[parseFormFieldsToFeatureAttributes]
+ * :param feature: ``OpenLayers.Feature.Vector``
+ * Copy each form field value attribute values to its corresponding
+ * attribute of a feature.
+ */
+ parseFormFieldsToFeatureAttributes: function(feature){
+ var field, id, value, fieldSet;
+
+ fieldSet = this.findById(this.attributeFieldSetId);
+
+ for(var i=0; i<fieldSet.items.length; i++){
+ field = fieldSet.items.get(i);
+ id = field.getName();
+ value = field.getValue();
+ feature.attributes[id] = value;
+ }
+ },
+
+ /** private: method[onAfterRender]
+ * Called after this element was rendered.
+ */
+ onAfterRender : function() {
+ var feature;
+
+ if(this.features.length != 1) {
+ return;
+ } else {
+ feature = this.features[0];
+ }
+
+ this.parseFeatureAttributesToFormFields(feature);
+ },
+
/** private: method[beforeDestroy]
*/
beforeDestroy: function() {
Modified: sandbox/redlining/ux/FeatureEditing/ux/widgets/form/RedLiningPanel.js
===================================================================
--- sandbox/redlining/ux/FeatureEditing/ux/widgets/form/RedLiningPanel.js 2010-01-12 19:12:42 UTC (rev 1726)
+++ sandbox/redlining/ux/FeatureEditing/ux/widgets/form/RedLiningPanel.js 2010-01-12 20:17:47 UTC (rev 1727)
@@ -33,7 +33,7 @@
* An array of attribute names to used when a blank feature is added
* to the map.
*/
- attributes: ['title','description'],
+ attributes: ['name','description'],
/** api: config[layer]
* ``OpenLayers.Layer.Vector``
Modified: sandbox/redlining/ux/FeatureEditing/ux/widgets/plugins/ExportFeature.js
===================================================================
--- sandbox/redlining/ux/FeatureEditing/ux/widgets/plugins/ExportFeature.js 2010-01-12 19:12:42 UTC (rev 1726)
+++ sandbox/redlining/ux/FeatureEditing/ux/widgets/plugins/ExportFeature.js 2010-01-12 20:17:47 UTC (rev 1727)
@@ -22,6 +22,7 @@
var layer = this.editFeatureForm.features[0].layer;
var features = this.editFeatureForm.features;
+ this.controler.triggerAutoSave();
GeoExt.ux.data.Export.KMLExport(map, layer, features);
}
});
More information about the Commits
mailing list