Add to several relations at once. Closes #3485
authorRichard Fairhurst <richard@systemed.net>
Fri, 28 Jan 2011 14:32:20 +0000 (14:32 +0000)
committerRichard Fairhurst <richard@systemed.net>
Fri, 28 Jan 2011 14:32:20 +0000 (14:32 +0000)
net/systemeD/potlatch2/RelationSelectPanel.mxml

index 5c58d66..4a1a2b9 100644 (file)
         }
         
         public function updateEntityAndClose():void {
-                       var relation:Relation = conn.getRelation(relationSelector.selectedItem.relId);
-                       if (entity is EntityCollection) {
-                               var undo:CompositeUndoableAction = new CompositeUndoableAction("Add to relation");
-                               for each (var e:Entity in EntityCollection(entity).entities) {
-                                       if (relation.findEntityMemberIndex(e)==-1) {
-                                               relation.appendMember(new RelationMember(e, ''), undo.push);
+                       var undo:CompositeUndoableAction = new CompositeUndoableAction("Add to relation");
+                       for each (var relObject:Object in relationSelector.selectedItems) {
+                               var relation:Relation = conn.getRelation(relObject.relId);
+                               if (entity is EntityCollection) {
+                                       for each (var e:Entity in EntityCollection(entity).entities) {
+                                               if (relation.findEntityMemberIndex(e)==-1) {
+                                                       relation.appendMember(new RelationMember(e, ''), undo.push);
+                                               }
                                        }
+                               } else {
+                                       relation.appendMember(new RelationMember(entity, ''), undo.push);
                                }
-                               MainUndoStack.getGlobalStack().addAction(undo);
-                       } else {
-                               relation.appendMember(new RelationMember(entity, ''), MainUndoStack.getGlobalStack().addAction);
                        }
+                       MainUndoStack.getGlobalStack().addAction(undo);
                        PopUpManager.removePopUp(this);
         }
         
         
     ]]></mx:Script> 
     <mx:Text id="warning" text="" />
-    <mx:List width="100%" height="100%" id="relationSelector" verticalScrollPolicy="on"> 
+    <mx:List width="100%" height="100%" id="relationSelector" verticalScrollPolicy="on" allowMultipleSelection="true" 
     </mx:List>
     <mx:ControlBar>
       <mx:Button label="New Relation..." click="closeAndNewRelation();" styleName="titleWindowButton" />
       <mx:Spacer width="100%"/>
-      <mx:Button label="Select" click="updateEntityAndClose();" enabled="{relationSelector.selectedItem != null? true : false}" styleName="titleWindowButton" />
+      <mx:Button label="Select" click="updateEntityAndClose();" enabled="{relationSelector.selectedItems.length>0}" styleName="titleWindowButton" />
     </mx:ControlBar>
 </mx:TitleWindow>