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' }
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;
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 );
$('#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/>");
if( editable ) {
$( '#dialog-form' ).dialog( {
autoOpen: false,
- height: 270,
+ height: 350,
width: 330,
modal: true,
buttons: {
$.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 );
});
$("#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 ) {
// 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 () {
<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> </label>
<br/>