From d3ad455d90d9baf292e18f84d90ace6907a06675 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Tue, 10 Sep 2024 15:39:53 +0000 Subject: [PATCH] Bug 37883: Add ability to filter search results location column by logged in location To test: 1. Apply patch, restart_all, and regenerate CSS ( https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_interface ) I also recommend clearing your browser cache. 2. Do a catalog search and notice the 'Show local items only' button above the "Location" column. 3. Click it to show information ( in that column ) that is only related to the branch you are currently logged in at. 4. In the same result set have some items that are checked out, withdrawn, lost, damaged, and notforlaon. 5. Play more with the search results and ensure everything is accurate. --- catalogue/search.pl | 3 ++ .../prog/css/src/staff-global.scss | 7 ++++- .../prog/en/modules/catalogue/results.tt | 30 +++++++++++++++---- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/catalogue/search.pl b/catalogue/search.pl index ebb78bcfb6e..8ecbe49e9ab 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -198,6 +198,9 @@ my ($template, $borrowernumber, $cookie) = get_template_and_user({ my $lang = C4::Languages::getlanguage($cgi); +my $userenv_branch = C4::Context->userenv->{'branch'} || ''; +$template->param( userbranch => $userenv_branch ); + if (C4::Context->preference("marcflavour") eq "UNIMARC" ) { $template->param('UNIMARC' => 1); } diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss index 2bc5c5db27a..38eb560b915 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -1942,7 +1942,6 @@ li { &.unavailable { clear: left; - display: block; } } @@ -1959,6 +1958,12 @@ li { display: block; } } + .all { + display: block; + } + .branch_specific { + display: none; + } } #searchresults, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt index e2dcdb6ff87..95d0b1391ca 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -451,7 +451,7 @@
[% INCLUDE 'page-numbers.inc' %] - +
[% IF ( searchdesc ) %] [% FOREACH QUERY_INPUT IN QUERY_INPUTS %] @@ -611,7 +611,10 @@ [% END %] - [% tnx('{count} item', '{count} items', SEARCH_RESULT.items_count, {count = SEARCH_RESULT.items_count}) | html %][% IF ( SEARCH_RESULT.availablecount ) %], [% SEARCH_RESULT.availablecount | html %] available:[% ELSE %], None available[% END %] +
[% tnx('{count} item', '{count} items', SEARCH_RESULT.items_count, {count = SEARCH_RESULT.items_count}) | html %][% IF ( SEARCH_RESULT.availablecount ) %], [% SEARCH_RESULT.availablecount | html %] available:[% ELSE %], None available[% END %]
+ [% IF SEARCH_RESULT.branchtotalcount > 0 %] +
[% tnx('{count} item', '{count} items', SEARCH_RESULT.branchtotalcount, {count = SEARCH_RESULT.branchtotalcount}) | html %][% IF ( SEARCH_RESULT.branchavailablecount ) %], [% SEARCH_RESULT.branchavailablecount | html %] available:[% ELSE %], None available[% END %]
+ [% END %] [% IF MaxSearchResultsItemsPerRecordStatusCheck && SEARCH_RESULT.items_count > MaxSearchResultsItemsPerRecordStatusCheck %]
@@ -621,11 +624,13 @@ [% BLOCK search_result_items %] [% IF status_count == "onloancount" %] [% IF SEARCH_RESULT.${status_count} > 0 %] -
[% SEARCH_RESULT.${status_count} | html %] checked out:
+
[% SEARCH_RESULT.${status_count} | html %] checked out:
+
[% SEARCH_RESULT.branchonloancount | html %] checked out:
[% END %] [% ELSIF status_count == "othercount" %] [% IF SEARCH_RESULT.${status_count} > 0 %] -
[% SEARCH_RESULT.${status_count} | html %] unavailable:
+
[% SEARCH_RESULT.${status_count} | html %] unavailable:
+
[% SEARCH_RESULT.branchothercount | html %] unavailable:
[% END %] [% END %] [% IF SEARCH_RESULT.${items_loop}.size > 0 %] @@ -704,9 +709,12 @@ [% END %] [% ELSE %] - No items + No items [% END %] [% END # /IF ( SEARCH_RESULT.items_count ) %] + [% IF SEARCH_RESULT.branchtotalcount == 0 %] + No items + [% END %]
@@ -816,6 +824,18 @@ var biblionumber = "[% biblionumber | html %]"; var holdfor_cardnumber = "[% holdfor_patron.cardnumber | html %]"; var holdforclub = "[% holdforclub | html %]"; + var userbranch = "[% userbranch | html %]"; + + $('#toggleitems').click( function() { + $('#toggleitems').text() === 'Show local items only' ? $('#toggleitems').text("Show items in all libraries") : $('#toggleitems').text("Show local items only"); + $('.branch_specific').toggle(); + $('.all').toggle(); + $('ul[class*="_loop_items"] li').each( function() { + if ( !$(this).hasClass(userbranch) ) { + $(this).toggle(); + } + }); + }); [% IF SEARCH_RESULTS %] var SEARCH_RESULTS = 1; [% ELSE %] -- 2.39.2