Refactor markComplete to POST to /status, and implement for ways too. Don't kill...
authorAndy Allan <andy@gravitystorm.co.uk>
Fri, 17 Jun 2011 12:44:15 +0000 (13:44 +0100)
committerAndy Allan <andy@gravitystorm.co.uk>
Fri, 17 Jun 2011 12:44:15 +0000 (13:44 +0100)
net/systemeD/potlatch2/utils/SnapshotConnection.as

index 6709b27..e77ae3b 100644 (file)
@@ -13,25 +13,33 @@ package net.systemeD.potlatch2.utils {
 
         /** Send a "complete" call to the server, and remove it from the current layer */
         public function markComplete(entity:Entity):void {
+            var urlReq:URLRequest;
+            var loader:URLLoader = new URLLoader();
             if (entity is Node) {
-              var node:Node = Node(entity);
-              if (node == getNode(node.id)) { // confirm it's from this connection
-                  var urlReq:URLRequest = new URLRequest(apiBaseURL+"node/"+node.id+"/complete");
-                  urlReq.method = "POST";
-                  urlReq.data = '   ';
-                  urlReq.contentType = "application/xml";
-                  urlReq.requestHeaders = [ new URLRequestHeader("X_HTTP_METHOD_OVERRIDE", "PUT"),
-                                            new URLRequestHeader("X-Error-Format", "XML") ];
-                  var loader:URLLoader = new URLLoader();
-                  loader.addEventListener(Event.COMPLETE, function(e:Event):void { killNode(node.id) });
-                  loader.load(urlReq);
-              }
+                var node:Node = Node(entity);
+                if (node == getNode(node.id)) { // confirm it's from this connection
+                    urlReq = new URLRequest(apiBaseURL+"node/"+node.id+"/status");
+                    urlReq.method = "POST";
+                    urlReq.data = 'complete';
+                    loader.addEventListener(Event.COMPLETE, function(e:Event):void { updateStatus(node, 'complete') });
+                    loader.load(urlReq);
+                }
 
             } else if (entity is Way) {
-              var way:Way = Way(entity);
-              trace("not implemented");
+                var way:Way = Way(entity);
+                if (way == getWay(way.id)) { // confirm it's from this connection
+                    urlReq = new URLRequest(apiBaseURL+"way/"+way.id+"/status");
+                    urlReq.method = "POST";
+                    urlReq.data = 'complete';
+                    loader.addEventListener(Event.COMPLETE, function(e:Event):void { updateStatus(way, 'complete') });
+                    loader.load(urlReq);
+                }
             }
         }
 
+        private function updateStatus(e:Entity, s:String):void {
+            e.setStatus(s);
+        }
+
     }
 }
\ No newline at end of file