BEGIN { extends 'Catalyst::Controller' }
+sub throw {
+ Text::Tradition::Error->throw(
+ 'ident' => 'Collation error',
+ 'message' => $_[0],
+ );
+}
+
+
=head1 NAME
stemmaweb::Controller::Relation - Controller for the relationship mapper
}
}
+ my @nodes;
+ push @nodes, "$readings[$first]";
+
for (my $i = $first+1; $i < $len; $i++) {
my $rdg = $readings[$first];
my $next = $readings[$i];
last unless $next->is_combinable;
+ push @nodes, "$next";
- warn "Joining readings $rdg and $next\n";
+ try {
+ $collation->merge_readings( "$rdg", "$next", 1 );
+ } catch ($e) {
+ $c->stash->{result} = {
+ error_msg => $e->message,
+ };
- $collation->merge_readings( "$rdg", "$next", 1 );
+ $c->detach('View::JSON');
+ }
}
- # Finally, make sure we haven't screwed anything up.
- foreach my $wit ( $tradition->witnesses ) {
- my $pathtext = $collation->path_text( $wit->sigil );
- throw( "Text differs for witness " . $wit->sigil )
- unless $pathtext eq $origtext{$wit->sigil};
- if( $wit->is_layered ) {
- my $acsig = $wit->sigil . $collation->ac_label;
- $pathtext = $collation->path_text( $acsig );
- throw( "Layered text differs for witness " . $wit->sigil )
- unless $pathtext eq $origtext{$acsig};
+ try {
+ # Finally, make sure we haven't screwed anything up.
+ foreach my $wit ( $tradition->witnesses ) {
+ my $pathtext = $collation->path_text( $wit->sigil );
+ throw( "Text differs for witness " . $wit->sigil )
+ unless $pathtext eq $origtext{$wit->sigil};
+ if( $wit->is_layered ) {
+ my $acsig = $wit->sigil . $collation->ac_label;
+ $pathtext = $collation->path_text( $acsig );
+ throw( "Layered text differs for witness " . $wit->sigil )
+ unless $pathtext eq $origtext{$acsig};
+ }
}
+ } catch ($e) {
+ $c->stash->{result} = {
+ error_msg => $e->message,
+ };
+
+ $c->detach('View::JSON');
}
+
$collation->relations->rebuild_equivalence();
$collation->calculate_ranks();
$m->save($collation);
- $c->stash->{'result'} = {};
+
+ $c->stash->{'result'} = {
+ success => 1,
+ nodes => \@nodes,
+ };
+
$c->forward('View::JSON');
}
}
var reltypes = {};
var readingdata = {};
var text_direction = 'LR';
-var current_selected = [];
jQuery.removeFromArray = function(value, arr) {
return jQuery.grep(arr, function(elem, index) {
function compress_nodes(readings) {
//add text of other readings to 1st reading
- for (var i = 1; i < readings.length; i++) {
- var first = get_ellipse(readings[0]);
- var cur = get_ellipse(readings[i]);
- var first_title = first.parent().find('text')[0];
+ var first = get_ellipse(readings[0]);
+ var first_title = first.parent().find('text')[0];
+
+ for (var i = 1; i < readings.length; i++) {
+ var cur = get_ellipse(readings[i]);
var cur_title = cur.parent().find('text')[0];
first_title.textContent += " " + cur_title.textContent;
}
});
if( $('ellipse[fill="#9999ff"]').size() > 0 ) {
- current_selected = readings;
-
//add intersection of witnesses sets to the multi select form and open it
$('#detach_collated_form').empty();
$('#action-detach').change(function() {
if ($('#action-detach')[0].checked) {
$('#detach_collated_form').show();
+ $('#multipleselect-form-text').show();
$('#detach_btn').show();
$('#merge_btn').hide();
$('#action-merge').change(function() {
if ($('#action-merge')[0].checked) {
$('#detach_collated_form').hide();
+ $('#multipleselect-form-text').hide();
$('#detach_btn').hide();
$('#merge_btn').show();
var form_values = $('#detach_collated_form').serialize();
var jqjson = $.post(ncpath, form_values, function(data) {
- compress_nodes(current_selected);
- current_selected = [];
+ if (data.success) {
+ if (data.nodes) {
+ compress_nodes(data.nodes);
+ }
+
+ mybuttons.button('enable');
+ self.dialog('close');
+ } else if (data.error_msg) {
+ document.getElementById('duplicate-merge-error').innerHTML = data.error_msg;
+ mybuttons.button('enable');
- mybuttons.button('enable');
- self.dialog('close');
+ }
});
}
},