From: Tara L Andrews Date: Wed, 22 Feb 2012 15:20:02 +0000 (+0100) Subject: save and display relationship annotations X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=69a19c917ed3a2303f3beb7f669c55e7f1bedb47;p=scpubgit%2Fstemmaweb.git save and display relationship annotations --- diff --git a/lib/stemmaweb/Controller/Relation.pm b/lib/stemmaweb/Controller/Relation.pm index 54830ac..832a447 100644 --- a/lib/stemmaweb/Controller/Relation.pm +++ b/lib/stemmaweb/Controller/Relation.pm @@ -97,9 +97,10 @@ sub relationships :Chained('text') :PathPart :Args(0) { my @all_relations; foreach my $p ( @pairs ) { my $relobj = $collation->relations->get_relationship( @$p ); - push( @all_relations, - { source => $p->[0], target => $p->[1], - type => $relobj->type, scope => $relobj->scope } ); + my $relhash = { source => $p->[0], target => $p->[1], + type => $relobj->type, scope => $relobj->scope }; + $relhash->{'note'} = $relobj->annotation if $relobj->has_annotation; + push( @all_relations, $relhash ); } $c->stash->{'result'} = \@all_relations; } elsif( $c->request->method eq 'POST' ) { @@ -110,8 +111,8 @@ sub relationships :Chained('text') :PathPart :Args(0) { my $scope = $c->request->param('scope'); my $opts = { 'type' => $relation, - 'scope' => $scope, - 'annotation' => $note }; + 'scope' => $scope }; + $opts->{'annotation'} = $note if $note; try { my @vectors = $collation->add_relationship( $node, $target, $opts ); diff --git a/root/js/relationship.js b/root/js/relationship.js index b135c71..2cbd7ee 100644 --- a/root/js/relationship.js +++ b/root/js/relationship.js @@ -57,6 +57,7 @@ function add_relations() { var relation = relation_manager.create( rel_info.source, rel_info.target, type_index ); relation.data( 'type', rel_info.type ); relation.data( 'scope', rel_info.scope ); + relation.data( 'note', rel_info.note ); var node_obj = get_node_obj(rel_info.source); node_obj.set_draggable( false ); node_obj.ellipse.data( 'node_obj', null ); @@ -341,7 +342,11 @@ function relation_factory() { } } this.showinfo = function(relation) { - $('#delete-form-text').html( 'type: ' + relation.data( 'type' ) + '
scope: ' + relation.data( 'scope' ) ); + var htmlstr = 'type: ' + relation.data( 'type' ) + '
scope: ' + relation.data( 'scope' ); + if( relation.data( 'note' ) ) { + htmlstr = htmlstr + '
note: ' + relation.data( 'note' ); + } + $('#delete-form-text').html( htmlstr ); var points = relation.children('path').attr('d').slice(1).replace('C',' ').split(' '); var xs = parseFloat( points[0].split(',')[0] ); var xe = parseFloat( points[1].split(',')[0] ); @@ -454,6 +459,7 @@ $(document).ready(function () { 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" ); @@ -501,7 +507,7 @@ $(document).ready(function () { $( "#delete-form" ).dialog({ autoOpen: false, - height: 120, + height: 135, width: 160, modal: false, buttons: {