From f63f7f7371d0ac2fae68fa8fec637a19964a62e6 Mon Sep 17 00:00:00 2001 From: Richard Fairhurst Date: Sat, 11 Jun 2011 11:18:58 +0100 Subject: [PATCH] Provide a new 'View data' button in the upload dialogue. 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 | 2 +- net/systemeD/halcyon/connection/XMLConnection.as | 8 ++++++-- net/systemeD/potlatch2/save/SaveDialog.mxml | 15 ++++++++++++--- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/net/systemeD/halcyon/connection/Connection.as b/net/systemeD/halcyon/connection/Connection.as index 56f474e0..4b2dbe41 100644 --- a/net/systemeD/halcyon/connection/Connection.as +++ b/net/systemeD/halcyon/connection/Connection.as @@ -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; } diff --git a/net/systemeD/halcyon/connection/XMLConnection.as b/net/systemeD/halcyon/connection/XMLConnection.as index 0e6bb844..d87d87ee 100644 --- a/net/systemeD/halcyon/connection/XMLConnection.as +++ b/net/systemeD/halcyon/connection/XMLConnection.as @@ -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 = 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 { diff --git a/net/systemeD/potlatch2/save/SaveDialog.mxml b/net/systemeD/potlatch2/save/SaveDialog.mxml index 4d87dd13..676c446c 100644 --- a/net/systemeD/potlatch2/save/SaveDialog.mxml +++ b/net/systemeD/potlatch2/save/SaveDialog.mxml @@ -64,9 +64,14 @@ + + + + + @@ -168,7 +173,11 @@ 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 { @@ -178,7 +187,7 @@ 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"); } @@ -197,7 +206,7 @@ processSequence.selectedChild = failureTab; failureText = text; } - + private function close():void { _connection.removeEventListener(Connection.NEW_CHANGESET, changesetCreated); _connection.removeEventListener(Connection.NEW_CHANGESET_ERROR, changesetError); -- 2.30.0