Bug 41422: Fix I18N issue with FilterSearchResultsByLoggedInBranch

To test:
1. Apply patch
2. Search fof the FilterSearchResultsByLoggedInBranch system preference and set it to 'Do'.
3. Do a catalog search and notice the 'Show local items only' button above the "Location" column.
4. Click it to show information ( in that column ) that is only related to the branch you are currently logged in at.
5. In the same result set have some items that are checked out, withdrawn, lost, damaged, and notforlaon.
6. Play more with the search results and ensure everything is accurate.
7. Set the FilterSearchResultsByLoggedInBranch system preference to 'Don't' and confirm that there is no button to filter by branch anymore.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
This commit is contained in:
Lucas Gass 2025-12-10 17:16:33 +00:00 committed by Laura Escamilla
parent 57dc4c7c20
commit ba6d2d29f0
No known key found for this signature in database
GPG Key ID: 6B1D9CA1AF817BC3
1 changed files with 14 additions and 6 deletions

View File

@ -556,7 +556,10 @@
<div id="searchresults">
[% INCLUDE 'page-numbers.inc' %]
[% IF Koha.Preference('FilterSearchResultsByLoggedInBranch') %]
<button href="#" id="toggleitems" class="btn btn-primary btn-xs show-local-items" style="float: right;">Show local items only</button>
<button id="toggleitems" class="btn btn-primary btn-xs" data-mode="all" style="float: right;">
<span class="when-all">[% t("Show local items only") | html %]</span>
<span class="when-local" style="display:none">[% t("Show items in all libraries") | html %]</span>
</button>
[% END %]
<form action="/cgi-bin/koha/catalogue/search.pl" method="get" name="bookbag_form" id="bookbag_form">
[% IF ( searchdesc ) %]
@ -986,7 +989,12 @@
}
});
$('#toggleitems').click( function() {
$('#toggleitems').text() === 'Show local items only' ? $('#toggleitems').text("Show items in all libraries") : $('#toggleitems').text("Show local items only");
let this_toggle = $(this);
let show_all = this_toggle.data('mode') === 'all';
this_toggle.find('.when-local, .when-all').toggle();
this_toggle.data('mode', show_all ? 'local' : 'all');
$('.branch_specific').toggle();
$('.all').toggle();
$('ul[class*="_loop_items"] li').each( function() {
@ -994,11 +1002,11 @@
$(this).toggle();
}
});
$(this).toggleClass('show-local-items show-all-items');
if ($(this).hasClass('show-local-items')) {
localStorage.setItem("show_local_items", 'all');
} else {
if (show_all) {
localStorage.setItem("show_local_items", 'local');
} else {
localStorage.setItem("show_local_items", 'all');
}
});
[% END %]