add help text to relationship mapper
[scpubgit/stemmatology.git] / stemmaweb / lib / stemmaweb / Controller / Relation.pm
index 690f44e..4ca7a25 100644 (file)
@@ -29,6 +29,19 @@ sub index :Path :Args(0) {
        $c->stash->{'template'} = 'relate.tt';
 }
 
+=head2 help
+
+ GET relation/help
+
+Returns the help window HTML.
+
+=cut
+
+sub help :Local :Args(0) {
+       my( $self, $c ) = @_;
+       $c->stash->{'template'} = 'relatehelp.tt';
+}
+
 =head2 definitions
 
  GET relation/definitions
@@ -97,9 +110,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' ) {
@@ -111,6 +125,7 @@ sub relationships :Chained('text') :PathPart :Args(0) {
        
                my $opts = { 'type' => $relation,
                                         'scope' => $scope };
+               $opts->{'annotation'} = $note if $note;
                
                try {
                        my @vectors = $collation->add_relationship( $node, $target, $opts );