Browse Source

Bug 11299: (follow-up) adjust tests for bug 26641, fix styling, fix population of new record

This corrects parameters in tests to adjust for new parameter in LinkBibHeadings

We also add lines to remove classes before adding the correct class while linking and restore
a missing class to the icons

Lastly we correct fetching the paramters to pass to authority creation popup to ensure
values are populated on save

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
21.05.x
Nick Clemens 7 months ago
committed by Jonathan Druart
parent
commit
3a1dea7612
  1. 9
      koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt
  2. 2
      koha-tmpl/intranet-tmpl/prog/js/cataloging.js
  3. 15
      t/db_dependent/Biblio.t

9
koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt

@ -192,7 +192,7 @@ function addCreateAuthorityButton(tag_subfield_line, heading, tag_index) {
var elem = $('<a href="#" title="' + title + '"><i class="fa fa-plus-circle"></i></a>');
tag_subfield_line.append(elem);
var tag_subfield_line_a = $('.subfield_line[id^=subfield' + heading.tag + 'a]').eq(tag_index);
var subfield_a = tag_subfield_line_a.children('.input_marceditor').eq(0);
var subfield_a = tag_subfield_line_a.find('.input_marceditor').eq(0);
var index = subfield_a.attr('id');
elem.click(function() {
var popup = window.open("", "new_auth_popup",'fullscreen,toolbar=false,scrollbars=yes');
@ -267,6 +267,7 @@ function updateHeadingLinks(links) {
if( tag_subfield_line.length < 1 ){ return; }
var subfield = tag_subfield_line.find('.input_marceditor').eq(0);
subfield.removeClass("matching_authority_field no_matching_authority_field");
// Delete the old status if one exists
tag_subfield_line.children('.subfield_status').remove();
@ -282,17 +283,17 @@ function updateHeadingLinks(links) {
subfield.val(heading.authid);
// Add the new status
var image = '<i class="fa fa-close no_matching_authority" </i> ';
var image = '<i class="fa fa-close subfield_status no_matching_authority" </i> ';
var message = '';
var field_class = 'no_matching_authority_field';
switch(heading.status) {
case 'LOCAL_FOUND':
image = '<i class="fa fa-check matching_authority"</i> ';
image = '<i class="fa fa-check subfield_status matching_authority"</i> ';
message = _("A matching authority was found in the local database.");
field_class = 'matching_authority_field';
break;
case 'CREATED':
image = '<i class="fa fa-check matching_authority"></i> ';
image = '<i class="fa fa-check subfield_status matching_authority"></i> ';
message = _("No matching authority found. A new authority was created automatically.");
field_class = 'matching_authority_field';
break;

2
koha-tmpl/intranet-tmpl/prog/js/cataloging.js

@ -189,7 +189,7 @@ function CloneField(index, hideMarc, advancedMARCEditor) {
inputs[j].value = "";
//Remove the color added by the automatic linker
$(inputs[j]).css({backgroundColor:""});
$(inputs[j]).removeClass("matching_authority_field no_matching_authority_field");
}
}
var textareas = divs[i].getElementsByTagName('textarea');

15
t/db_dependent/Biblio.t

@ -745,13 +745,14 @@ subtest "LinkBibHeadingsToAuthorities record generation tests" => sub {
t::lib::Mocks::mock_preference('AutoCreateAuthorities', '1');
my $linker = C4::Linker::Default->new();
my $record = MARC::Record->new();
my $biblio = $builder->build_sample_biblio();
my $record = $biblio->metadata->record;
# Generate a record including all valid subfields and an invalid one 'e'
my $field = MARC::Field->new('650','','','a' => 'Beach city', 'b' => 'Weirdness', 'v' => 'Fiction', 'x' => 'Books', 'y' => '21st Century', 'z' => 'Fish Stew Pizza', 'e' => 'Depicted');
$record->append_fields($field);
my ( $num_headings_changed, $results ) = LinkBibHeadingsToAuthorities($linker, $record, "",undef);
my ( $num_headings_changed, $results ) = LinkBibHeadingsToAuthorities($linker, $record, "",undef,650);
is( $num_headings_changed, 1, 'We changed the one we passed' );
is_deeply( $results->{added},
@ -767,8 +768,8 @@ subtest "LinkBibHeadingsToAuthorities record generation tests" => sub {
);
#Add test for this case using verbose
( $num_headings_changed, $results ) = LinkBibHeadingsToAuthorities($linker, $record, "",undef, 1);
my $details = $results->{details};
$record->field('650')->delete_subfield('9');
( $num_headings_changed, $results ) = LinkBibHeadingsToAuthorities($linker, $record, "",undef, 650, 1);
is( $num_headings_changed, 1, 'We changed the one we passed' );
is( $results->{details}->[0]->{status}, 'CREATED', "We added an authority record for the heading using verbose");
@ -781,11 +782,10 @@ subtest "LinkBibHeadingsToAuthorities record generation tests" => sub {
);
# Example series link with volume and punctuation
$record = MARC::Record->new();
$field = MARC::Field->new('800','','','a' => 'Tolkien, J. R. R.', 'q' => '(John Ronald Reuel),', 'd' => '1892-1973.', 't' => 'Lord of the rings ;', 'v' => '1');
$record->append_fields($field);
( $num_headings_changed, $results ) = LinkBibHeadingsToAuthorities($linker, $record, "",undef);
( $num_headings_changed, $results ) = LinkBibHeadingsToAuthorities($linker, $record, "",undef, 800);
is( $num_headings_changed, 1, 'We changed the one we passed' );
is_deeply( $results->{added},
@ -801,7 +801,8 @@ subtest "LinkBibHeadingsToAuthorities record generation tests" => sub {
);
# The same example With verbose
( $num_headings_changed, $results ) = LinkBibHeadingsToAuthorities($linker, $record, "",undef, 1);
$record->field('800')->delete_subfield('9');
( $num_headings_changed, $results ) = LinkBibHeadingsToAuthorities($linker, $record, "",undef, 800, 1);
is( $num_headings_changed, 1, 'We changed the one we passed' );
is( $results->{details}->[0]->{status}, 'CREATED', "We added an authority record for the heading using verbose");

Loading…
Cancel
Save