X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fstemmaweb%2FController%2FRelation.pm;h=0a0579ca5977e0d1ff97644d51aff0e81b57d9f9;hb=89aae3eec7a0e23f314597cd09bd3ffc696c7412;hp=7b75c8ec07f35d9df99d3fd10a4d9c80c140cb6e;hpb=e4bdf6606498d358c80e45b8cee69250b3bee6d3;p=scpubgit%2Fstemmaweb.git diff --git a/lib/stemmaweb/Controller/Relation.pm b/lib/stemmaweb/Controller/Relation.pm index 7b75c8e..0a0579c 100644 --- a/lib/stemmaweb/Controller/Relation.pm +++ b/lib/stemmaweb/Controller/Relation.pm @@ -70,7 +70,10 @@ sub main :Chained('text') :PathPart('') :Args(0) { my( $self, $c ) = @_; my $tradition = delete $c->stash->{'tradition'}; my $collation = $tradition->collation; - + + # Stash text direction to use in JS. + $c->stash->{'direction'} = $collation->direction; + # Stash the relationship definitions $c->stash->{'relationship_scopes'} = to_json( find_type_constraint( 'RelationshipScope' )->values ); @@ -133,7 +136,7 @@ sub main :Chained('text') :PathPart('') :Args(0) { $c->stash->{'startseg'} = $startseg if defined $startseg; $c->stash->{'svg_string'} = $svg_str; $c->stash->{'text_title'} = $tradition->name; - if( $tradition->can('language') ) { + if( $tradition->can('language') && $tradition->language ) { $c->stash->{'text_lang'} = $tradition->language; $c->stash->{'can_morphologize'} = 1; } else { @@ -253,6 +256,7 @@ sub relationships :Chained('text') :PathPart :Args(0) { delete $opts->{scope} unless $opts->{scope}; delete $opts->{annotation} unless $opts->{annotation}; + delete $opts->{is_significant} unless $opts->{is_significant}; $opts->{propagate} = 1; try { @@ -261,7 +265,10 @@ sub relationships :Chained('text') :PathPart :Args(0) { $m->save( $tradition ); } catch( Text::Tradition::Error $e ) { $c->response->status( '403' ); - $c->stash->{'result'} = { 'error' => $e->message }; + $c->stash->{'result'} = { error => $e->message }; + } catch { + $c->response->status( '500' ); + $c->stash->{'result'} = { error => "Something went wrong with the request" }; } } elsif( $c->request->method eq 'DELETE' ) { my $node = $c->request->param('source_id'); @@ -275,7 +282,10 @@ sub relationships :Chained('text') :PathPart :Args(0) { } catch( Text::Tradition::Error $e ) { $c->response->status( '403' ); $c->stash->{'result'} = { 'error' => $e->message }; - } + } catch { + $c->response->status( '500' ); + $c->stash->{'result'} = { error => "Something went wrong with the request" }; + } } } $c->forward('View::JSON'); @@ -395,7 +405,7 @@ sub reading :Chained('text') :PathPart :Args(1) { $errmsg = $e->message; } catch { # Something else went wrong, probably a Moose error - $c->response->status( '403' ); + $c->response->status( '500' ); $errmsg = 'Something went wrong with the request'; } } @@ -579,7 +589,7 @@ sub duplicate :Chained('text') :PathPart :Args(0) { $errmsg = $e->message; } catch { # Something else went wrong, probably a Moose error - $c->response->status( '403' ); + $c->response->status( '500' ); $errmsg = 'Something went wrong with the request'; } if( $newrdg ) {