From: Tara L Andrews Date: Thu, 18 Jul 2013 03:57:14 +0000 (+0200) Subject: look for deleted relations as result of node duplication. Issue #17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2Fstemmaweb.git;a=commitdiff_plain;h=217f5e6414a51ebdbdedfd3ce3656d5c731a664c look for deleted relations as result of node duplication. Issue #17 --- diff --git a/lib/stemmaweb/Controller/Relation.pm b/lib/stemmaweb/Controller/Relation.pm index ca3a459..467ac90 100644 --- a/lib/stemmaweb/Controller/Relation.pm +++ b/lib/stemmaweb/Controller/Relation.pm @@ -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; } } diff --git a/root/js/relationship.js b/root/js/relationship.js index a056ee7..e36243c 100644 --- a/root/js/relationship.js +++ b/root/js/relationship.js @@ -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