add is_significant attribute to relationships. Closes #33
tla [Tue, 21 Jan 2014 15:05:15 +0000 (16:05 +0100)]
lib/stemmaweb/Controller/Relation.pm
root/css/dashboard.css
root/css/style.css
root/js/relationship.js
root/src/relate.tt

index c5f3281..7b75c8e 100644 (file)
@@ -1,8 +1,10 @@
 package stemmaweb::Controller::Relation;
 use JSON qw/ to_json from_json /;
 use Moose;
+use Moose::Util::TypeConstraints qw/ find_type_constraint /;
 use Module::Load;
 use namespace::autoclean;
+use Text::Tradition::Datatypes;
 use TryCatch;
 
 BEGIN { extends 'Catalyst::Controller' }
@@ -70,7 +72,10 @@ sub main :Chained('text') :PathPart('') :Args(0) {
        my $collation = $tradition->collation;
        
        # Stash the relationship definitions
-       $c->stash->{'relationship_scopes'} = to_json( [ qw/ local global / ] );
+       $c->stash->{'relationship_scopes'} = 
+               to_json( find_type_constraint( 'RelationshipScope' )->values );
+       $c->stash->{'ternary_values'} = 
+               to_json( find_type_constraint( 'Ternary' )->values );
        my @reltypeinfo;
        foreach my $type ( sort { _typesort( $a, $b ) } $collation->relations->types ) {
                next if $type->is_weak;
@@ -208,6 +213,7 @@ sub relationships :Chained('text') :PathPart :Args(0) {
                                  a_derivable_from_b => $relobj->a_derivable_from_b,
                                  b_derivable_from_a => $relobj->b_derivable_from_a,
                                  non_independent => $relobj->non_independent,
+                                 is_significant => $relobj->is_significant
                                  };
                        $relhash->{'note'} = $relobj->annotation if $relobj->has_annotation;
                        push( @all_relations, $relhash );
index aded615..1386ee0 100644 (file)
     top: 10px;
     margin-bottom: 24px;
 }
-.error {
-    font-weight: bold;
-    color: #ff3333;
-}
-.notification {
-       font-weight: bold;
-       color: #33ff33;
-}
 #new_file {
     position: absolute;
     top: -50px;
index 33344aa..5d55a48 100644 (file)
@@ -136,4 +136,11 @@ div.pager_left_button.greyed_out, div.pager_left_button.greyed_out:hover {
        color: #ffffff;
        text-decoration: underline;
 }
-
+.error {
+    font-weight: bold;
+    color: #ff3333;
+}
+.notification {
+       font-weight: bold;
+       color: #33ff33;
+}
index cf40f3e..0e253d8 100644 (file)
@@ -600,6 +600,14 @@ function relation_factory() {
        $('#delete_relation_type').text( relation.data('type') );
        $('#delete_relation_scope').text( relation.data('scope') );
        $('#delete_relation_attributes').empty();
+       var significance = ' is not ';
+       if( relation.data( 'is_significant' ) === 'yes') {
+               significance = ' is ';
+       } else if ( relation.data( 'is_significant' ) === 'maybe' ) {
+               significance = ' might be ';
+       }
+               $('#delete_relation_attributes').append( 
+                       "This relationship" + significance + "stemmatically significant<br/>");
        if( relation.data( 'a_derivable_from_b' ) ) {
                $('#delete_relation_attributes').append( 
                        "'" + relation.data('source_text') + "' derivable from '" + relation.data('target_text') + "'<br/>");
@@ -1050,7 +1058,7 @@ $(document).ready(function () {
   if( editable ) {
        $( '#dialog-form' ).dialog( {
        autoOpen: false,
-       height: 270,
+       height: 350,
        width: 330,
        modal: true,
        buttons: {
@@ -1100,11 +1108,15 @@ $(document).ready(function () {
                $.each( relationship_scopes, function(index, value) {   
                         $('#scope').append( $('<option />').attr( "value", value ).text(value) ); 
                });
-               // Handler to clear the annotation field, the first time the relationship is
-               // changed after opening the form.
+               $.each( ternary_values, function( index, value ) {
+                       $('#is_significant').append( $('<option />').attr( "value", value ).text(value) );
+               });
+               // Handler to reset fields to default, the first time the relationship 
+               // is changed after opening the form.
                $('#rel_type').change( function () {
                        if( !$(this).data( 'changed_after_open' ) ) {
                                $('#note').val('');
+                               $(this).find(':checked').removeAttr('checked');
                        }
                        $(this).data( 'changed_after_open', true );
                });
@@ -1132,7 +1144,8 @@ $(document).ready(function () {
                $("#dialog_overlay").hide();
        }
        }).ajaxError( function(event, jqXHR, ajaxSettings, thrownError) {
-               if( ajaxSettings.url == getTextURL('relationships') 
+               if( ( ajaxSettings.url == getTextURL('relationships')
+                         || ajaxSettings.url == getTextURL('merge') )
                        && ajaxSettings.type == 'POST' && jqXHR.status == 403 ) {
                        var error;
                        if( jqXHR.responseText.indexOf('do not have permission to modify') > -1 ) {
index f97c638..9b4e350 100644 (file)
@@ -12,12 +12,15 @@ var editable = "[% permission %]" === "full";
 // URLs for images referenced in Javascript
 var merge_button_yes = "[% c.uri_for( '/images/tick_circle_frame.png' ) %]";
 var merge_button_no = "[% c.uri_for( '/images/no_entry.png' ) %]";
+// Constants used in Javascript that we get from the server
 [% IF error -%]
 var relationship_types = [];
 var relationship_scopes = [];
+var ternary_values = [];
 [% ELSE -%]
 var relationship_types = [% relationship_types %];
 var relationship_scopes = [% relationship_scopes %];
+var ternary_values = [% ternary_values %];
 [% END -%]
 
 $(document).ready(function () {
@@ -74,6 +77,11 @@ $(document).ready(function () {
                                <option></option>
                        </select>
                        <br/><br/>
+                       <label for="is_significant">Is this variance stemmatically significant?</label>
+                       <select name="is_significant" id="is_significant" class=".ui-widget select"/>
+                               <option></option>
+                       </select>
+                       <br/><br/>
                        <input type="checkbox" name="b_derivable_from_a" id="b_derivable_from_a"/>
                        <label for="b_derivable_from_a"><span class="rel_rdg_a"></span> would be corrected to <span class="rel_rdg_b"></span>&nbsp;</label>
                        <br/>