kill stupid tab bug
[potlatch2.git] / net / systemeD / potlatch2 / RelationSelectPanel.mxml
index 136fa9e804de91b4be31dae87721141ac7b7bd45..6e95fceba1441f08aba08eeb37881209e144b529 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 = {}; for (var k:String in t) { tags[k]=t[k]; } // deep copy tags
           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,9 +46,9 @@
         }
         
         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(
               PopUpManager.createPopUp(Application(Application.application), RelationEditorPanel, true));
           panel.setRelation(relation);
@@ -62,4 +64,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>