From: tla Date: Wed, 17 Jun 2015 12:02:16 +0000 (+0200) Subject: Include text direction as editable attribute of a tradition X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2Fstemmaweb.git;a=commitdiff_plain;h=62175f90e73cac092d87d163dad957e19305528b Include text direction as editable attribute of a tradition --- diff --git a/lib/stemmaweb/Controller/Root.pm b/lib/stemmaweb/Controller/Root.pm index 66a0d92..9a0d3f4 100644 --- a/lib/stemmaweb/Controller/Root.pm +++ b/lib/stemmaweb/Controller/Root.pm @@ -278,6 +278,20 @@ sub textinfo :Local :Args(1) { $changed = 1 if $ispublic; } + # Handle text direction + my $tdval = delete $params->{direction} || 'LR'; + + unless( $tradition->collation->direction + && $tradition->collation->direction eq $tdval ) { + try { + $tradition->collation->change_direction( $tdval ); + $changed = 1; + } catch { + return _json_error( $c, 500, "Error setting direction to $tdval: $@" ); + } + } + + # Handle ownership change if( exists $params->{'owner'} ) { # Only admins can update user / owner @@ -317,6 +331,7 @@ sub textinfo :Local :Args(1) { my $textinfo = { textid => $textid, name => $tradition->name, + direction => $tradition->collation->direction || 'LR', public => $tradition->public || 0, owner => $tradition->user ? $tradition->user->email : undef, witnesses => [ map { $_->sigil } $tradition->witnesses ], diff --git a/root/js/componentload.js b/root/js/componentload.js index 76fe2df..60757c6 100644 --- a/root/js/componentload.js +++ b/root/js/componentload.js @@ -503,7 +503,7 @@ $(document).ready( function() { $("#edit_textinfo_status").empty(); // Populate the form fields with the current values // edit_(name, language, public, owner) - $.each([ 'name', 'language', 'owner' ], function( idx, k ) { + $.each([ 'name', 'language', 'owner', 'direction' ], function( idx, k ) { var fname = '#edit_' + k; // Special case: language Default is basically language null if( k == 'language' && selectedTextInfo[k] == 'Default' ) { diff --git a/root/src/index.tt b/root/src/index.tt index ad6ab59..2437e54 100644 --- a/root/src/index.tt +++ b/root/src/index.tt @@ -120,6 +120,12 @@ var textOnLoad = "[% withtradition %]";
+ +
[% IF c.user_exists -%] [% IF c.user.get_object.is_admin -%]