look for deleted relations as result of node duplication. Issue #17
Tara L Andrews [Thu, 18 Jul 2013 03:57:14 +0000 (05:57 +0200)]
lib/stemmaweb/Controller/Relation.pm
root/js/relationship.js

index ca3a459..467ac90 100644 (file)
@@ -536,11 +536,14 @@ sub duplicate :Chained('text') :PathPart :Args(0) {
                
                # Otherwise, do the dirty work.
                my @witlist = keys %wits;
+               my @deleted_relations;
                foreach my $rank ( sort { $a <=> $b } keys %rdgranks ) {
                        my $newrdg;
                        my $reading_id = $rdgranks{$rank};
+                       my @delrels;
                        try {
-                               $newrdg = $collation->duplicate_reading( $reading_id, @witlist );
+                               ( $newrdg, @delrels ) = 
+                                       $collation->duplicate_reading( $reading_id, @witlist );
                        } catch( Text::Tradition::Error $e ) {
                                $c->response->status( '403' );
                                $errmsg = $e->message;
@@ -553,12 +556,14 @@ sub duplicate :Chained('text') :PathPart :Args(0) {
                                my $data = _reading_struct( $newrdg );
                                $data->{'orig_rdg'} = $reading_id;
                                $response->{"$newrdg"} = $data;
+                               push( @deleted_relations, @delrels );
                        }
                } 
                if( $errmsg ) {
                        $c->stash->{'result'} = { 'error' => $errmsg };
                } else {
                        $m->save( $collation );
+                       $response->{'DELETED'} = \@deleted_relations;
                        $c->stash->{'result'} = $response;
                }
        }
index a056ee7..e36243c 100644 (file)
@@ -664,7 +664,8 @@ function draw_relation( source_id, target_id, relation_color ) {
 }
 
 function detach_node( readings ) {
-    
+    // separate out the deleted relationships, discard for now
+    delete readings['DELETED'];
     // add new node(s)
     $.extend( readingdata, readings );
     // remove from existing readings the witnesses for the new nodes/readings