do the 'Add to route' button in the route editor
[potlatch2.git] / net / systemeD / potlatch2 / RelationSelectPanel.mxml
index 136fa9e804de91b4be31dae87721141ac7b7bd45..0f7301f30accb338ed053d5b305ea18bb05d6add 100644 (file)
         private var conn:Connection;
         private var relationList:Array;
         private var entity:Entity;
+               private var tags:Object;
 
-        public function init(e:Entity):void {
+        public function init(e:Entity, t:Object):void {
           entity = e;
+                 tags = t;
           PopUpManager.addPopUp(this, Application(Application.application), true);
           PopUpManager.centerPopUp(this);
     
           var titles:Array = [];
           conn = Connection.getConnectionInstance();
-          relationList = conn.getAllRelationIDs();
+          relationList = conn.getMatchingRelationIDs(tags);
           if (relationList.length == 0) {
-            warning.text = "No relations loaded";
+            warning.text = "No relations available";
           } else {
             warning.text = "These relations are available:";
           }
@@ -44,7 +46,8 @@
         }
         
         public function closeAndNewRelation():void {
-          var relation:Relation = conn.createRelation({}, [new RelationMember(entity, '')])
+          var relation:Relation = conn.createRelation(tags, [new RelationMember(entity, '')],
+              MainUndoStack.getGlobalStack().addAction)
           PopUpManager.removePopUp(this);
           trace("edit relation "+id);
           var panel:RelationEditorPanel = RelationEditorPanel(
@@ -62,4 +65,4 @@
       <mx:Spacer width="100%"/>
       <mx:Button label="Select" click="updateEntityAndClose();" enabled="{relationSelector.selectedItem != null? true : false}"/>
     </mx:ControlBar>
-</mx:TitleWindow>
\ No newline at end of file
+</mx:TitleWindow>