Delete relations when last member removed
authorRichard Fairhurst <richard@systemeD.net>
Thu, 8 Mar 2012 17:42:19 +0000 (17:42 +0000)
committerRichard Fairhurst <richard@systemeD.net>
Thu, 8 Mar 2012 17:42:19 +0000 (17:42 +0000)
net/systemeD/halcyon/connection/Relation.as

index a02dbe6..85fa050 100644 (file)
@@ -100,11 +100,19 @@ package net.systemeD.halcyon.connection {
         }
 
                public function removeMember(entity:Entity, performAction:Function):void {
-                       performAction(new RemoveEntityFromRelationAction(this, entity, members));
+                       if (length>1) {
+                               performAction(new RemoveEntityFromRelationAction(this, entity, members));
+                       } else {
+                               performAction(new DeleteRelationAction(this, setDeletedState, members));
+                       }
                }
 
         public function removeMemberByIndex(index:uint, performAction:Function):void {
-            performAction(new RemoveMemberByIndexAction(this, members, index));
+                       if (length>1) {
+                               performAction(new RemoveMemberByIndexAction(this, members, index));
+                       } else {
+                               performAction(new DeleteRelationAction(this, setDeletedState, members));
+                       }
         }
 
                public override function remove(performAction:Function):void {