Bugzilla – Attachment 178773 Details for
Bug 37883
Add a filter for staff search results to filter by library
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37883: Add ability to filter search results location column by logged in location
Bug-37883-Add-ability-to-filter-search-results-loc.patch (text/plain), 11.01 KB, created by
Lucas Gass (lukeg)
on 2025-02-26 23:11:13 UTC
(
hide
)
Description:
Bug 37883: Add ability to filter search results location column by logged in location
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-02-26 23:11:13 UTC
Size:
11.01 KB
patch
obsolete
>From 93bca003436536478d8bea78ff8b38077b6a4777 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Wed, 26 Feb 2025 23:07:56 +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 | 8 +++ > .../prog/en/modules/catalogue/results.tt | 58 +++++++++++++++---- > 3 files changed, 59 insertions(+), 10 deletions(-) > >diff --git a/catalogue/search.pl b/catalogue/search.pl >index b64f0551b05..91ce2fa0908 100755 >--- a/catalogue/search.pl >+++ b/catalogue/search.pl >@@ -200,6 +200,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 47e85450abc..283b2f4d60f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >+++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >@@ -2026,6 +2026,14 @@ 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 ade947fd89d..53e1360e2e3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >@@ -554,7 +554,7 @@ > [% ELSE # /IF scan %] > <div id="searchresults"> > [% INCLUDE 'page-numbers.inc' %] >- >+ <button href="#" id="toggleitems" class="btn btn-primary btn-xs" style="float: right;">Show local items only</button> > <form action="/cgi-bin/koha/catalogue/search.pl" method="get" name="bookbag_form" id="bookbag_form"> > [% IF ( searchdesc ) %] > [% FOREACH QUERY_INPUT IN QUERY_INPUTS %] >@@ -747,17 +747,39 @@ > <div class="results_available_count"> > [% IF MaxSearchResultsItemsPerRecordStatusCheck && SEARCH_RESULT.items_count > MaxSearchResultsItemsPerRecordStatusCheck %] > <span class="blocker inaccurate-item-statuses" title="Item statuses may be inaccurate. Please view the record details for accurate item statuses"> >+ <div class="all"> >+ [% tnx('{count} item', '{count} items', SEARCH_RESULT.items_count, {count = SEARCH_RESULT.items_count}) | html %][% IF ( SEARCH_RESULT.availablecount ) %] >+ , [% SEARCH_RESULT.availablecount | html %] <span>available:</span> >+ [% ELSE %] >+ , <span>None available</span> >+ [% END %] >+ </div> >+ [% IF SEARCH_RESULT.branchtotalcount > 0 %] >+ <div class="branch_specific"> >+ [% tnx('{count} item', '{count} items', SEARCH_RESULT.branchtotalcount, {count = SEARCH_RESULT.branchtotalcount}) | html %][% IF ( SEARCH_RESULT.branchavailablecount ) %] >+ , [% SEARCH_RESULT.branchavailablecount | html %] <span>available:</span> >+ [% ELSE %] >+ , <span>None available</span> >+ [% END %] >+ </div> >+ [% END %] >+ </span> >+ [% ELSE %] >+ <div class="all"> > [% tnx('{count} item', '{count} items', SEARCH_RESULT.items_count, {count = SEARCH_RESULT.items_count}) | html %][% IF ( SEARCH_RESULT.availablecount ) %] > , [% SEARCH_RESULT.availablecount | html %] <span>available:</span> > [% ELSE %] > , <span>None available</span> > [% END %] >- </span> >- [% ELSE %] >- [% tnx('{count} item', '{count} items', SEARCH_RESULT.items_count, {count = SEARCH_RESULT.items_count}) | html %][% IF ( SEARCH_RESULT.availablecount ) %] >- , [% SEARCH_RESULT.availablecount | html %] <span>available:</span> >- [% ELSE %] >- , <span>None available</span> >+ </div> >+ [% IF SEARCH_RESULT.branchtotalcount > 0 %] >+ <div class="branch_specific"> >+ [% tnx('{count} item', '{count} items', SEARCH_RESULT.branchtotalcount, {count = SEARCH_RESULT.branchtotalcount}) | html %][% IF ( SEARCH_RESULT.branchavailablecount ) %] >+ , [% SEARCH_RESULT.branchavailablecount | html %] <span>available:</span> >+ [% ELSE %] >+ , <span>None available</span> >+ [% END %] >+ </div> > [% END %] > [% END %] > </div> >@@ -766,11 +788,13 @@ > [% BLOCK search_result_items %] > [% IF status_count == "onloancount" %] > [% IF SEARCH_RESULT.${status_count} > 0 %] >- <div class="results_checkedout">[% SEARCH_RESULT.${status_count} | html %] checked out:</div> >+ <div class="results_checkedout all">[% SEARCH_RESULT.${status_count} | html %] checked out:</div> >+ <div class="results_checkedout branch_specific">[% SEARCH_RESULT.branchonloancount | html %] checked out:</div> > [% END %] > [% ELSIF status_count == "othercount" %] > [% IF SEARCH_RESULT.${status_count} > 0 %] >- <div class="results_unavailable">[% SEARCH_RESULT.${status_count} | html %] unavailable:</div> >+ <div class="results_unavailable all">[% SEARCH_RESULT.${status_count} | html %] unavailable:</div> >+ <div class="results_unavailable branch_specific">[% SEARCH_RESULT.branchothercount | html %] unavailable:</div> > [% END %] > [% END %] > [% IF SEARCH_RESULT.${items_loop}.size > 0 %] >@@ -848,9 +872,12 @@ > [% END %] > </ul> > [% ELSE %] >- <span class="unavailable">No items</span> >+ <span class="unavailable all">No items</span> > [% END %] > [% END # /IF ( SEARCH_RESULT.items_count ) %] >+ [% IF SEARCH_RESULT.branchtotalcount == 0 %] >+ <span class="unavailable branch_specific">No items</span> >+ [% END %] > </div> > <!-- /.availability --> > </td> >@@ -935,6 +962,17 @@ > 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.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 37883
:
171256
|
171257
|
171261
|
171286
|
171287
|
171289
|
171291
|
171406
|
171407
|
171408
|
171409
|
171410
|
171411
|
176697
|
177306
|
177784
|
177785
|
177786
|
177787
|
177788
|
177789
|
177790
|
177791
|
178772
| 178773 |
178774
|
178775
|
178776
|
178777