Actually delete invalid relationships on duplicate. Fixes #17
Tara L Andrews [Thu, 18 Jul 2013 13:33:01 +0000 (15:33 +0200)]
root/js/relationship.js

index 6eb672f..c98077b 100644 (file)
@@ -665,7 +665,18 @@ function draw_relation( source_id, target_id, relation_color ) {
 
 function detach_node( readings ) {
     // separate out the deleted relationships, discard for now
-    delete readings['DELETED'];
+    if( 'DELETED' in readings ) {
+       // Remove each of the deleted relationship links.
+       $.each( readings['DELETED'], function( idx, pair ) {
+               var relation_id = get_relation_id( pair[0], pair[1] );
+                       var relation = $( jq( relation_id ) );
+                       if( relation.size() == 0 ) { 
+                       relation_id = get_relation_id( pair[1], pair[0] );
+               }
+               relation_manager.remove( relation_id );
+       });
+       delete readings['DELETED'];
+    }
     // add new node(s)
     $.extend( readingdata, readings );
     // remove from existing readings the witnesses for the new nodes/readings