work in progress for marking nodes as complete
authorAndy Allan <andy@gravitystorm.co.uk>
Fri, 10 Jun 2011 16:55:35 +0000 (17:55 +0100)
committerAndy Allan <andy@gravitystorm.co.uk>
Fri, 10 Jun 2011 16:55:35 +0000 (17:55 +0100)
net/systemeD/potlatch2/panels/BackgroundPanel.mxml
net/systemeD/potlatch2/utils/SnapshotConnection.as

index cd60f01..982feb2 100644 (file)
       <mx:DataGridColumn editable="false" dataField="value" headerText="value" />
     </mx:columns>
   </mx:DataGrid>
+  <mx:Text text="All the data copied to the main layer? Click 'complete'!" />
+  <mx:Button label="Complete" click="markComplete()"/>
   <mx:Script><![CDATA[
 
       import net.systemeD.halcyon.connection.*;
       import net.systemeD.halcyon.MapPaint;
+      import net.systemeD.potlatch2.utils.SnapshotConnection;
       import mx.collections.*;
 
       private var selectedEntity:Entity;
             for each(var tag:Tag in tags) { tagDataProvider.addItem(tag); }
       }
 
+      private function markComplete():void {
+            if (selectedEntity.connection is SnapshotConnection) {
+                SnapshotConnection(selectedEntity.connection).markComplete(selectedEntity);
+            }
+      }
       ]]>
   </mx:Script>
 </mx:VBox>
\ No newline at end of file
index 5159e09..4910cf5 100644 (file)
@@ -1,6 +1,8 @@
 package net.systemeD.potlatch2.utils {
 
-    import net.systemeD.halcyon.connection.XMLConnection;
+    import net.systemeD.halcyon.connection.*;
+    import flash.events.Event;
+    import flash.net.*;
 
     public class SnapshotConnection extends XMLConnection {
 
@@ -8,7 +10,27 @@ package net.systemeD.potlatch2.utils {
             super(cname,api,policy,initparams);
         }
 
-        /* todo - stuff about marking nodes/ways as complete */
+        /** Send a "complete" call to the server, and remove it from the current layer */
+        public function markComplete(entity:Entity):void {
+            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);
+              }
+
+            } else if (entity is Way) {
+              var way:Way = Way(entity);
+              trace("not implemented");
+            }
+        }
 
     }
 }
\ No newline at end of file