Update dupes when node is moved / deleted. Needs further refactoring
[potlatch2.git] / net / systemeD / halcyon / connection / Entity.as
index ec5884a329771c2dbfaf45daf42ce5b31ff1d782..392a890a16d622ac5d7a67b6637ed2953436220c 100644 (file)
@@ -143,6 +143,12 @@ package net.systemeD.halcyon.connection {
                
                public function setDeletedState(isDeleted:Boolean):void {
                    deleted = isDeleted;
+            if (this is Node) {
+              var n:Node = Node(this);
+              Connection.getConnection().removeDupe(n);
+            } else if (this is Node) {
+              Connection.getConnection().addDupe(n.id, n.lat, n.lon);
+            }
                }
                
                internal function isEmpty():Boolean {
@@ -213,10 +219,10 @@ package net.systemeD.halcyon.connection {
                        return a;
                }
                
-               public function findParentRelationsOfType(type:String, role:String=""):Array {
+               public function findParentRelationsOfType(type:String, role:String=null):Array {
                        var a:Array=[];
                        for (var o:Object in parents) {
-                               if (o is Relation && Relation(o).tagIs('type',type) && Relation(o).hasMemberInRole(this,role)) { 
+                               if (o is Relation && Relation(o).tagIs('type',type) && (role==null || Relation(o).hasMemberInRole(this,role))) { 
                                        a.push(o);
                                }
                        }