Delete relations when last member removed
[potlatch2.git] / net / systemeD / halcyon / connection / Relation.as
index a02dbe6bf1a677c54c8648be29ef884b1d910297..85fa0505f94bbfd168d1277eb41908e345377e35 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 {