suppress relationship drawing on out-of-range nodes on global rel creation
Tara L Andrews [Sat, 28 Apr 2012 19:53:16 +0000 (21:53 +0200)]
root/js/relationship.js

index ed1b150..bd78e31 100644 (file)
@@ -485,11 +485,15 @@ $(document).ready(function () {
         $(':button :contains("Ok")').attr("disabled", true);
         var jqjson = $.post( ncpath, form_values, function(data) {
             $.each( data, function(item, source_target) { 
-                var relation = relation_manager.create( source_target[0], source_target[1], $('#rel_type').attr('selectedIndex') );
-                relation.data( 'type', $('#rel_type :selected').text()  );
-                relation.data( 'scope', $('#scope :selected').text()  );
-                relation.data( 'note', $('#note').val()  );
-                relation_manager.toggle_active( relation.children('title').text() );
+               var source_found = get_ellipse( source_target[0] );
+               var target_found = get_ellipse( source_target[1] );
+               if( source_found.size() && target_found.size() ) {
+                                       var relation = relation_manager.create( source_target[0], source_target[1], $('#rel_type').attr('selectedIndex') );
+                                       relation.data( 'type', $('#rel_type :selected').text()  );
+                                       relation.data( 'scope', $('#scope :selected').text()  );
+                                       relation.data( 'note', $('#note').val()  );
+                                       relation_manager.toggle_active( relation.children('title').text() );
+                               }
             });
             $( "#dialog-form" ).dialog( "close" );
         }, 'json' );