Include text direction as editable attribute of a tradition
tla [Wed, 17 Jun 2015 12:02:16 +0000 (14:02 +0200)]
lib/stemmaweb/Controller/Root.pm
root/js/componentload.js
root/src/index.tt

index 66a0d92..9a0d3f4 100644 (file)
@@ -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 ],
index 76fe2df..60757c6 100644 (file)
@@ -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' ) {
index ad6ab59..2437e54 100644 (file)
@@ -120,6 +120,12 @@ var textOnLoad = "[% withtradition %]";
                <input id="edit_language" type="text" size="12" name="language"/>
                <label for="edit_public">Publicly viewable: </label>
                <input id="edit_public" type="checkbox" name="public"/><br/>
+               <label for="edit_direction">Text direction: </label>
+               <select id="edit_direction" name="direction">
+                       <option value="LR" selected>Left-to-right</option>
+                       <option value="RL">Right-to-left</option>
+                       <option value="BI">Bidirectional</option>
+               </select><br/>
 [% IF c.user_exists -%]
 [% IF c.user.get_object.is_admin -%]
                <label for="edit_owner">Tradition owner: </label>