Provide a new 'View data' button in the upload dialogue.
authorRichard Fairhurst <richard@systemeD.net>
Sat, 11 Jun 2011 10:18:58 +0000 (11:18 +0100)
committerRichard Fairhurst <richard@systemeD.net>
Sat, 11 Jun 2011 10:18:58 +0000 (11:18 +0100)
If the upload freaks out and refuses to save, the user can at least copy and paste the raw XML for later use.

net/systemeD/halcyon/connection/Connection.as
net/systemeD/halcyon/connection/XMLConnection.as
net/systemeD/potlatch2/save/SaveDialog.mxml

index 56f474e..4b2dbe4 100644 (file)
@@ -582,7 +582,7 @@ package net.systemeD.halcyon.connection {
         public function setAccessToken(key:String, secret:String):void {}
            public function createChangeset(tags:Object):void {}
                public function closeChangeset():void {}
-           public function uploadChanges():void {}
+        public function uploadChanges():* {}
         public function fetchUserTraces(refresh:Boolean=false):void {}
         public function fetchTrace(id:Number, callback:Function):void {}
         public function hasAccessToken():Boolean { return false; }
index 0e6bb84..d87d87e 100644 (file)
@@ -197,7 +197,10 @@ package net.systemeD.halcyon.connection {
             loader.load(urlReq);
         }
 
-        override public function uploadChanges():void {
+               /** Create XML changeset and send it to the server. Returns the XML string for use in the 'Show data' button.
+                   (We don't mind what's returned as long as it implements .toString() ) */
+
+        override public function uploadChanges():* {
             var changeset:Changeset = getActiveChangeset();
             var upload:XML = <osmChange version="0.6"/>
             upload.appendChild(addCreated(changeset, getAllNodeIDs, getNode, serialiseNode));
@@ -230,7 +233,8 @@ package net.systemeD.halcyon.connection {
                        serv.addEventListener(FaultEvent.FAULT, diffUploadIOError);
                        serv.send(upload);
                
-               dispatchEvent(new Event(SAVE_STARTED));
+                       dispatchEvent(new Event(SAVE_STARTED));
+                       return upload;
         }
 
         private function diffUploadComplete(event:ResultEvent):void {
index 4d87dd1..676c446 100644 (file)
       <mx:Text width="100%" styleName="failText" text="{failureText}"/>
     </mx:VBox>
 
+    <mx:VBox width="100%" height="100%" id="dataTab">
+      <mx:TextArea width="100%" height="100%" id="dataText"/>
+    </mx:VBox>
+
   </mx:ViewStack>
 
   <mx:ControlBar>
+    <mx:Button id="dataButton" label="View data" visible="false" click="processSequence.selectedChild=dataTab" styleName="titleWindowButton" />
     <mx:Spacer width="100%"/>
     <mx:Button id="cancelButton" label="Cancel" click="close();" styleName="titleWindowButton" />
     <mx:Button id="saveButton" label="Save >" click="startSave();" styleName="titleWindowButton" />
         
         saveProgress.label = "Uploading changes";
         _connection.addEventListener(Connection.SAVE_COMPLETED, saveCompleted);
-        _connection.uploadChanges();
+        var rawData:*=_connection.uploadChanges();
+        if (rawData) {
+            dataText.text=rawData.toString();
+            dataButton.visible=true;
+        }
     }
     
     private function changesetError(event:Event):void {
     private function saveCompleted(event:SaveCompleteEvent):void {
         if ( event.saveOK ) {
                        _connection.dispatchEvent(new AttentionEvent(AttentionEvent.ALERT, null, "Changes successfully saved"));
-            close();
+            if (processSequence.selectedChild!=dataTab) close();
         } else {
             fail("Failure when uploading data");
                }
         processSequence.selectedChild = failureTab;
         failureText = text;
     }
-    
+
     private function close():void {
         _connection.removeEventListener(Connection.NEW_CHANGESET, changesetCreated);
         _connection.removeEventListener(Connection.NEW_CHANGESET_ERROR, changesetError);