From 3a1dea7612895d56ddd39095935b3d267e8ff97e Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 7 Jan 2021 14:27:09 +0000 Subject: [PATCH] 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 --- .../prog/en/modules/cataloguing/addbiblio.tt | 9 +++++---- koha-tmpl/intranet-tmpl/prog/js/cataloging.js | 2 +- t/db_dependent/Biblio.t | 15 ++++++++------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt index 2b5b8ee2fd..ea86100d2c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt @@ -192,7 +192,7 @@ function addCreateAuthorityButton(tag_subfield_line, heading, tag_index) { var elem = $(''); 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 = ' '; + var image = ' '; var message = ''; var field_class = 'no_matching_authority_field'; switch(heading.status) { case 'LOCAL_FOUND': - image = ' '; + image = ' '; message = _("A matching authority was found in the local database."); field_class = 'matching_authority_field'; break; case 'CREATED': - image = ' '; + image = ' '; message = _("No matching authority found. A new authority was created automatically."); field_class = 'matching_authority_field'; break; diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js index b7b9ab3d5c..64a9ebdce5 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js +++ b/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'); diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t index 21c39ae91c..3f970acdeb 100755 --- a/t/db_dependent/Biblio.t +++ b/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"); -- 2.39.5