From fc9e966d2b14a26e5da94eae160ba34e975dee17 Mon Sep 17 00:00:00 2001 From: Janusz Kaczmarek Date: Fri, 22 Nov 2024 23:04:56 +0000 Subject: [PATCH] Bug 38514: Filter out autocomplete list of authorities with ConsiderHeadingUse After adding ConsiderHeadingUse system preference we can limit search results of authority finder plugin to authorities useable in specyfic type of fields (based on 008/14-16 data in authorities record). The autocomplete feature in auth_finder.pl should obey the ConsiderHeadingUse setting. Test plan: ========== 0. Have a standard KTD enviromnent. 1. Apply Bug 38494. 2. Set ConsiderHeadingUse system preference to "Don't", ShowHeadingUse to 'Show'. 3. Go to the Cataloging editor and open the authority finder plugin for the 650 field. 4. Type "Application" in "Search main heading ($a only)" field. 5. Notice two autocomplete values: "Application program interfaces (Computer software)" and "Application software". 6. Click search button. 7. There are two result: "Application program interfaces (Computer software)" (the one with 'v' Subject in Heading Use column) and Application software Development (with 'x' Subject in Heading Use column). 8. Close the authority finder window, cancel the editor. Set ConsiderHeadingUse system preference to "Do". 9. Go to the Cataloging editor and open the authority finder plugin for the 650 field. 10. Type "Application" in "Search main heading ($a only)" field. 11. Notice two autocomplete values: "Application program interfaces (Computer software)" and "Application software". 12. Click search button. 13. There is only one result: "Application program interfaces (Computer software)" (the one with 'v' Subject in Heading Use column). So we get only one result but there were two autocomplete hints. 14. Apply the patch ; restart all ; clear the browser js cache (or go to a private browser window). 15. Repeat p. 9-10. 16. Notice that there is only one autocomplete hint: "Application program interfaces (Computer software)". 17. Click search button. 18. There is only one result: "Application program interfaces (Computer software)" (the one with 'v' Subject in Heading Use column). --- authorities/ysearch.pl | 34 +++++++++++++++---- .../prog/js/auth-finder-search.js | 4 +++ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/authorities/ysearch.pl b/authorities/ysearch.pl index 3a58fe9758..3f02af2069 100755 --- a/authorities/ysearch.pl +++ b/authorities/ysearch.pl @@ -49,14 +49,34 @@ if ( $auth_status ne "ok" ) { exit 0; } - my @value = $query->multi_param('term'); - my $searchtype = $query->param('querytype'); - my @marclist = ($searchtype); + my @value = $query->multi_param('term'); + my $searchtype = $query->param('querytype'); + my @marclist = ($searchtype); + my $index = $query->param('index'); my $authtypecode = $query->param('authtypecode'); - my @and_or = $query->multi_param('and_or'); - my @excluding = $query->multi_param('excluding'); - my @operator = $query->multi_param('operator'); - my $orderby = $query->param('orderby'); + my @and_or = $query->multi_param('and_or'); + my @excluding = $query->multi_param('excluding'); + my @operator = $query->multi_param('operator'); + my $orderby = $query->param('orderby'); + + if ( C4::Context->preference('ConsiderHeadingUse') ) { + my $marcflavour = C4::Context->preference('marcflavour'); + my $biblio_tag = substr( $index, 4, 3 ); + if ( $marcflavour eq 'MARC21' ) { + my $heading_use_search_field = + $biblio_tag =~ /^[127]/ ? 'Heading-use-main-or-added-entry' + : $biblio_tag =~ /^6/ ? 'Heading-use-subject-added-entry' + : $biblio_tag =~ /^[48]/ ? 'Heading-use-series-added-entry' + : undef; + if ($heading_use_search_field) { + push @marclist, $heading_use_search_field; + push @and_or, 'and'; + push @excluding, ''; + push @operator, 'is'; + push @value, 'a'; + } + } + } my $resultsperpage = 50; my $startfrom = 0; diff --git a/koha-tmpl/intranet-tmpl/prog/js/auth-finder-search.js b/koha-tmpl/intranet-tmpl/prog/js/auth-finder-search.js index 5bdf7db81a..d0177eab0d 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/auth-finder-search.js +++ b/koha-tmpl/intranet-tmpl/prog/js/auth-finder-search.js @@ -16,6 +16,7 @@ $(document).ready(function(){ url: "/cgi-bin/koha/authorities/ysearch.pl", dataType: "json", data: { + index : index, authtypecode : authtypecode, term: request.term, op: "do_search", @@ -47,6 +48,7 @@ $(document).ready(function(){ url: "/cgi-bin/koha/authorities/ysearch.pl", dataType: "json", data: { + index : index, authtypecode : authtypecode, term: request.term, op: "do_search", @@ -78,6 +80,7 @@ $(document).ready(function(){ url: "/cgi-bin/koha/authorities/ysearch.pl", dataType: "json", data: { + index : index, authtypecode : authtypecode, term: request.term, op: "do_search", @@ -109,6 +112,7 @@ $(document).ready(function(){ url: "/cgi-bin/koha/authorities/ysearch.pl", dataType: "json", data: { + index : index, authtypecode : authtypecode, term: request.term, op: "do_search", -- 2.39.5