[OpenLayers-Commits] r4744 - in sandbox/timandseb/wfsv: examples lib/OpenLayers/Control

commits at openlayers.org commits at openlayers.org
Mon Oct 1 17:43:39 EDT 2007


Author: sbenthall
Date: 2007-10-01 17:43:38 -0400 (Mon, 01 Oct 2007)
New Revision: 4744

Modified:
   sandbox/timandseb/wfsv/examples/wfs-v.html
   sandbox/timandseb/wfsv/lib/OpenLayers/Control/SaveFeatures.js
Log:
Cancel button works now

Modified: sandbox/timandseb/wfsv/examples/wfs-v.html
===================================================================
--- sandbox/timandseb/wfsv/examples/wfs-v.html	2007-10-01 21:08:14 UTC (rev 4743)
+++ sandbox/timandseb/wfsv/examples/wfs-v.html	2007-10-01 21:43:38 UTC (rev 4744)
@@ -219,16 +219,18 @@
         };
 		
 		
-		function addPopup(feature, content){
-			OpenLayers.Console.log("Creating Popup")
-			OpenLayers.Console.log(feature.geometry.getBounds().getCenterLonLat())
+		function addPopup(feature, content, recallOnHide){
+			//OpenLayers.Console.log("Creating Popup")
+			//OpenLayers.Console.log(feature.geometry.getBounds().getCenterLonLat())
 			popup = new OpenLayers.Popup.AnchoredBubble("chicken", 
                                     feature.geometry.getBounds().getCenterLonLat(),
                                     new OpenLayers.Size(250,75),
                                     content,
                                     null, true);
 									
-			popup.onHide = function () {recallFeature(feature)}
+			if(recallOnHide) {
+				popup.onHide = function () {recallFeature(feature)}
+			}
 									 
 			feature.popup = popup;
             map.addPopup(popup,true);	
@@ -253,9 +255,10 @@
 		function onViewStart(feature){
 			
 			
-			OpenLayers.Console.log("Feature _attributes_ have been recalled")
+			//OpenLayers.Console.log("Feature _attributes_ have been recalled")
+			OpenLayers.Console.log(feature)
+			OpenLayers.Console.log(feature.attributes)
 			
-			OpenLayers.Console.log(feature)
 			var view = document.createElement("div")
 			var table = document.createElement("table");
             var caption = document.createElement("caption");
@@ -263,7 +266,7 @@
             table.appendChild(caption);
             var tbody = document.createElement("tbody");
             var attr = feature.attributes;
-			OpenLayers.Console.log("Should be good until here")
+			//OpenLayers.Console.log("Should be good until here")
             var value, tr, td1, td2, valnode;
             var name = document.getElementById('layerName').value.split(' ')[0];
             for(var key in schema[name]) {
@@ -294,7 +297,7 @@
 			hist.innerHTML = "History"
 			view.appendChild(hist);
 			
-			OpenLayers.Console.log(view);
+			//OpenLayers.Console.log(view);
 				
 			addPopup(feature,view)
 			
@@ -309,9 +312,9 @@
     var ogcns = "http://www.opengis.net/ogc";
     var toppns = "http://www.openplans.org/topp";
 
-    function recallFeature(feature) {
-		OpenLayers.Console.log("recallFeature")
-		OpenLayers.Console.log(feature.geometry.getBounds().getCenterLonLat())
+    function recallFeature(feature, callback) {
+		//OpenLayers.Console.log("recallFeature")
+		//OpenLayers.Console.log(feature.geometry.getBounds().getCenterLonLat())
 		
         var getFeature = xml.createElementNS(wfsns, "wfs:GetFeature");
         getFeature.setAttribute("version", "1.0.0");
@@ -334,12 +337,26 @@
         }
 		
 		var xxyzzy = function(request){
-				var recalledFeature = panel.gml.read(request.responseXML);
 				
-				clientFeature = panel.vectorLayer.fids[feature.fid];
-            	
-				clientFeature.attributes = recalledFeature[0].attributes;
+				//OpenLayers.Console.log("xxyzzy")
 				
+				var recalledFeatureArray = panel.gml.read(request.responseXML);
+				var recalledFeature = recalledFeatureArray[0];
+				var name = document.getElementById('layerName').value.split(' ')[0];
+				
+				
+				for(var key in schema[name]) {
+		
+                    feature.attributes[key] = recalledFeature.attributes[key];
+
+                }
+				
+				if(feature.state != OpenLayers.State.INSERT) {
+                    feature.state = OpenLayers.State.UPDATE;
+                }
+				
+				if(callback) callback(feature);
+				
 				/*
 				 * if(potentialFeature) {
 				 *  	panel.vectorLayer.removeFeatures([potentialFeature]);             	   
@@ -418,7 +435,7 @@
 
         function onModificationStart(feature) {
 			
-			OpenLayers.Console.log("onModificationStart("+feature+")")
+			//OpenLayers.Console.log("onModificationStart("+feature+")")
 			
             var form = document.createElement("form");
             var table = document.createElement("table");
@@ -466,11 +483,11 @@
 			tabedit.appendChild(form);
 			var cancel = document.createElement('button')
 			cancel.innerHTML = "Cancel"
-			cancel.onclick = function () {OpenLayers.Console.log("Cancel will be broken until View and Modify take their information from a feature created by a new geoserver requesst as opposed to from the client-side stored feature (which needs to be modified in order for the panel to realize there has been something modified(?))"); onModificationEnd(feature); onViewStart(feature);}
+			cancel.onclick = function () {onModificationEnd(feature, function(f){ onViewStart(f)})}
 			tabedit.appendChild(cancel);
 			var save = document.createElement("button")
 			//save.type = "button"
-			save.onclick = function () {onModificationEnd(feature); panel.saveControl.trigger();}// }
+			save.onclick = function () { panel.saveControl.trigger();onModificationEnd(feature);}// }
 			save.innerHTML = "Save"
 			tabedit.appendChild(save);
 			
@@ -491,7 +508,7 @@
 			
 			//OpenLayers.Console.log(form)
 			
-			addPopup(feature,tabedit)
+			addPopup(feature,tabedit, true)
 			
 			/*
 			var element = document.getElementById("popup-output");
@@ -507,10 +524,10 @@
 		
 		
 
-        function onModificationEnd(feature) {
-			recallFeature(feature)
+        function onModificationEnd(feature, callback) {
 			
-			OpenLayers.Console.log('onModificationEnd(feature)')
+			
+			//OpenLayers.Console.log('onModificationEnd(feature)')
             var element = document.getElementById("output");
             element.innerHTML = "";
 			
@@ -518,13 +535,14 @@
 				map.removePopup(feature.popup);
             	feature.popup.destroy();
             	feature.popup = null;
-			}	
+			}
 			
+			recallFeature(feature, callback)
         }
 		
 		function requestShownFeatures(){
 			var bounds = map.calculateBounds();
-			OpenLayers.Console.log("requestShownFeatures()")
+			//OpenLayers.Console.log("requestShownFeatures()")
 			panel.prepareRequest(bounds,true);
 		}
 		

Modified: sandbox/timandseb/wfsv/lib/OpenLayers/Control/SaveFeatures.js
===================================================================
--- sandbox/timandseb/wfsv/lib/OpenLayers/Control/SaveFeatures.js	2007-10-01 21:08:14 UTC (rev 4743)
+++ sandbox/timandseb/wfsv/lib/OpenLayers/Control/SaveFeatures.js	2007-10-01 21:43:38 UTC (rev 4744)
@@ -67,7 +67,7 @@
      * force - {Boolean} Save without checking the this.condition().
      */
     trigger: function(force) {
-		OpenLayers.Console.log(this)
+		//OpenLayers.Console.log(this)
         if(force || this.condition()) {
             this.format.message = this.message;
             this.format.srsName = this.layer.projection;



More information about the Commits mailing list