Load relations from the server on supplying the ID
authorRichard Fairhurst <richard@systemeD.net>
Sat, 2 Apr 2011 18:14:20 +0000 (19:14 +0100)
committerRichard Fairhurst <richard@systemeD.net>
Sat, 2 Apr 2011 18:14:20 +0000 (19:14 +0100)
net/systemeD/halcyon/connection/XMLConnection.as
net/systemeD/potlatch2/RelationLoaderPanel.mxml [new file with mode: 0644]
net/systemeD/potlatch2/RelationSelectPanel.mxml

index 0bf342d..b94345b 100644 (file)
@@ -48,7 +48,7 @@ package net.systemeD.halcyon.connection {
 
                override public function loadEntity(entity:Entity):void {
                        var url:String=Connection.apiBaseURL + entity.getType() + "/" + entity.id;
-                       if (entity is Relation || entity is Way) url+="/full";
+                       if (entity is Way) url+="/full";
                        sendLoadRequest(new URLRequest(url));
                }
 
diff --git a/net/systemeD/potlatch2/RelationLoaderPanel.mxml b/net/systemeD/potlatch2/RelationLoaderPanel.mxml
new file mode 100644 (file)
index 0000000..b5c305e
--- /dev/null
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<mx:TitleWindow
+       xmlns:mx="http://www.adobe.com/2006/mxml"
+       xmlns:potlatch2="net.systemeD.potlatch2.*"
+       title="Load Relation" width="350" height="200"
+       showCloseButton="true" close="PopUpManager.removePopUp(this);">
+       
+       <mx:HBox>
+               <mx:Label text="Relation ID: " />
+               <mx:TextInput id="requestedID" restrict="0-9" />
+       </mx:HBox>
+    <mx:ControlBar>
+      <mx:Spacer width="100%"/>
+      <mx:Button label="Load" click="loadRelation();" styleName="titleWindowButton" />
+    </mx:ControlBar>
+       <mx:Script><![CDATA[
+               import net.systemeD.halcyon.*;
+               import net.systemeD.halcyon.connection.*;
+               import net.systemeD.potlatch2.*;
+               import mx.managers.PopUpManager;
+
+               // ** FIXME: should automatically focus on id field (like the Changeset dialogue)
+
+               public function loadRelation():void {
+            var conn:Connection = Connection.getConnectionInstance();
+                       var id:uint = uint(requestedID.text);
+                       if (requestedID.text) {
+                               var rel:Relation=conn.getRelation(id);
+                               if (!rel) {
+                                       rel = conn.createRelation({}, [], MainUndoStack.getGlobalStack().addAction);
+                                       rel.renumber(id,1);
+                               }
+                               conn.loadEntity(rel);
+                               // add an eventListener of some sort to pop up the panel again once it's loaded
+                       }
+                       PopUpManager.removePopUp(this);
+               }
+    ]]></mx:Script>    
+</mx:TitleWindow>
+
index 37a184f..8db158d 100644 (file)
                        panel.setRelation(relation);
                        PopUpManager.centerPopUp(panel);
         }
+
+               public function closeAndLoadRelation():void {
+                       PopUpManager.removePopUp(this);
+                       var panel:RelationLoaderPanel = RelationLoaderPanel(
+                           PopUpManager.createPopUp(Application(Application.application), RelationLoaderPanel, true));
+                       PopUpManager.centerPopUp(panel);
+               }
         
     ]]></mx:Script> 
     <mx:Text id="warning" text="" />
@@ -87,6 +94,7 @@
     </mx:List>
     <mx:ControlBar>
       <mx:Button label="New Relation..." click="closeAndNewRelation();" styleName="titleWindowButton" />
+      <mx:Button label="Load Relation..." click="closeAndLoadRelation();" styleName="titleWindowButton" />
       <mx:Spacer width="100%"/>
       <mx:Button label="Select" click="updateEntityAndClose();" enabled="{relationSelector.selectedItems.length>0}" styleName="titleWindowButton" />
     </mx:ControlBar>