update route editors when entity joins a relation
authorRichard Fairhurst <richard@systemed.net>
Mon, 14 Jun 2010 18:03:13 +0000 (18:03 +0000)
committerRichard Fairhurst <richard@systemed.net>
Mon, 14 Jun 2010 18:03:13 +0000 (18:03 +0000)
TODO.txt
net/systemeD/potlatch2/mapfeatures/editors/RelationMemberEditor.as
net/systemeD/potlatch2/mapfeatures/editors/RouteEditor.mxml

index 8ca909d..b7d598d 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -29,7 +29,6 @@ Potlatch 2: main outstanding issues
 == Tag editing ==
 
 ** Doesn't always update selected tab when you select a new entity
-** Doesn't update selected tab when you change the relations on an entity
 * Dynamic reloading of stylesheet/map_features, so that you don't need to reload the full page when editing them
 * If a select name is too long then, the select menu seems to give a horizontal scrollbar instead of the name of the item e.g. cuisine#Coffee Shop
 * If you have both inputSets names and buildingAddress, and name= key is filled in then the basic tab will get both, surely only name should be shown and building name should be ignored e.g. cafes. [Actually this was an issue of addr: being missing from one of them, however this may still be a problem for other overlapping inputSets]
index 8d371fb..f002cc2 100644 (file)
@@ -62,11 +62,12 @@ package net.systemeD.potlatch2.mapfeatures.editors {
       public function set entity(entity:Entity):void {
           _entity = entity;
           
-          // TODO: we need to listen for add/removal and relation tag changes
+          entity.addEventListener(Connection.ADDED_TO_RELATION, relationsChanged);
+          entity.addEventListener(Connection.REMOVED_FROM_RELATION, relationsChanged);
           dispatchEvent(new Event("relations_changed"));
       }
       
-      private function relationsChanged(event:TagEvent):void {
+      protected function relationsChanged(event:Event):void {
           dispatchEvent(new Event("relations_changed"));
       }
 
index 6ab87fc..22071dc 100644 (file)
@@ -18,7 +18,9 @@
     import mx.managers.PopUpManager;
     import mx.core.*;
    
-    public function addRoutes():void {
+    public function addRoutes(event:Event=null):void {
+               routeIcons.removeAllChildren();
+               addEventListener("routes_changed", addRoutes);
         for each(var relation:Object in matchedRelations) {
             var icon:RouteIcon = new RouteIcon();
             icon.setRoute(relation, RouteEditorFactory(_factory).icon);
     
     public function routeClicked(event:Event):void {
         var relation:Object = RouteIcon(event.currentTarget).route;
-        trace(relation+" is clicked");
         var panel:RelationEditorPanel = RelationEditorPanel(
             PopUpManager.createPopUp(Application(Application.application), RelationEditorPanel, true));
         panel.setRelation(relation["relation"]);
         PopUpManager.centerPopUp(panel);
     }
 
-      public function addToRelation():void {
-          new RelationSelectPanel().init(_entity, _factory.relationTags);        
-      }
-      
+       public function addToRelation():void {
+               new RelationSelectPanel().init(_entity, _factory.relationTags);        
+       }
+
+       override protected function relationsChanged(event:Event):void {
+               dispatchEvent(new Event("routes_changed"));
+       }
     
   ]]></mx:Script>
 </edit:RelationMemberEditor>