From 6893aca98387600815dcd83bedbeb126e0e087c0 Mon Sep 17 00:00:00 2001 From: Lari Taskula <lari.taskula@hypernova.fi> Date: Fri, 18 Oct 2024 20:32:10 +0000 Subject: [PATCH] Bug 15728: Add component records facet to staff client Test plan provided in "Support component records limit" commits. --- catalogue/search.pl | 21 +++++++++++++---- .../intranet-tmpl/prog/en/includes/facets.inc | 23 ++++++++++++++++++- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/catalogue/search.pl b/catalogue/search.pl index ba97a75f1c..0555b58833 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -400,13 +400,22 @@ if ($operands[0] && !$operands[1]) { $basic_search=1; } -my $available; +my ( $available, $component_records, $exclude_component_records ); foreach my $limit(@limits) { if ($limit =~/available/) { $available = 1; } + elsif ( $limit =~ /^component_records$/ ) { + $component_records = 1; + } elsif ( $limit =~ /^exclude_component_records$/ ) { + $exclude_component_records = 1; + } } -$template->param(available => $available); +$template->param( + available => $available, + limit_component_records => $component_records, + limit_exclude_component_records => $exclude_component_records, +); # append year limits if they exist my $limit_yr; @@ -648,9 +657,11 @@ for (my $i=0;$i<@servers;$i++) { if ($hits) { $template->param(total => $hits); if ($limit_cgi) { - my $limit_cgi_not_availablity = $limit_cgi; - $limit_cgi_not_availablity =~ s/&limit=available//g; - $template->param(limit_cgi_not_availablity => $limit_cgi_not_availablity); + foreach my $limit_case ( 'available', 'component_records', 'exclude_component_records' ) { + my $limit_cgi_not_case = $limit_cgi; + $limit_cgi_not_case = s/&limit=$limit_case//g if defined $limit_cgi_not_case; + $template->param( "limit_cgi_not_$limit_case" => $limit_cgi_not_case ); + } } $template->param(DisplayMultiPlaceHold => $DisplayMultiPlaceHold); if ($query_desc || $limit_desc) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc index 2e54fcb523..4ced1c2d8d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc @@ -34,7 +34,7 @@ <strong>Showing only records with available items</strong> </li> <li> - <a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi | $raw %][% limit_cgi_not_availablity | $raw %][% IF ( sort_by ) %]&sort_by=[% sort_by | uri %][% END %]">Show all records</a> + <a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi | $raw %][% limit_cgi_not_available | $raw %][% IF ( sort_by ) %]&sort_by=[% sort_by | uri %][% END %]">Show all records</a> [% ELSE %] <a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %][% IF ( sort_by ) %]&sort_by=[% sort_by | uri %][% END %]&limit=available">Limit to records with available items</a> [% END # /IF available %] @@ -47,6 +47,27 @@ [% END %] </li> <!-- /#availability_facet --> + [% IF Koha.Preference("ShowComponentRecordsFacet") == 'staff' || Koha.Preference("ShowComponentRecordsFacet") == 'both' %] + <li id="component_record_facet"> + Component records + <ul> + <li> + [% IF ( limit_exclude_component_records ) || ( limit_component_records ) %] + <strong>[% IF ( limit_exclude_component_records ) %]Excluding[% ELSE %]Showing only[% END %] component records</strong> + </li> + <li> + <a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi | $raw %][% IF ( limit_exclude_component_records ) %][% limit_cgi_not_limit_exclude_component_records %][% END %][% IF ( limit_component_records ) %][% limit_cgi_not_limit_component_records %][% END %][% IF ( sort_by ) %]&sort_by=[% sort_by | uri %][% END %]">Show all records</a> + [% ELSE %] + <a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %][% IF ( sort_by ) %]&sort_by=[% sort_by | uri %][% END %]&limit=exclude_component_records">Exclude component records</a> + </li> + <li> + <a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %][% IF ( sort_by ) %]&sort_by=[% sort_by | uri %][% END %]&limit=component_records">Show component records</a> + [% END # /IF limit_exclude_component_records %] + </li> + </ul> + </li> <!-- /#component_record_facet --> + [% END # /IF ShowComponentRecordsFacet %] + [% FOREACH facets_loo IN facets_loop %] [% IF facets_loo.facets.size > 0 %] <li id="[% facets_loo.type_id | html %]"> -- 2.34.1