From af2b8e544fcfefa1f6de01d5a89c755df2043dd2 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Tue, 10 Sep 2024 20:23:45 +0000 Subject: [PATCH] Bug 37883: Use Cookie to remember last selection Signed-off-by: Brendan Lawlor --- .../prog/en/modules/catalogue/results.tt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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 d23efc5ee9..1203a0ab7c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -452,7 +452,7 @@
[% INCLUDE 'page-numbers.inc' %] [% IF Koha.Preference('FilterSearchResultsByLoggedInBranch') %] - + [% END %]
[% IF ( searchdesc ) %] @@ -833,8 +833,13 @@ var userbranch = "[% userbranch | html %]"; [% IF Koha.Preference('FilterSearchResultsByLoggedInBranch') %] + $(document).ready( function() { + if ( Cookies.get("show_local_items") == 'local' ) { + $('#toggleitems').click(); + } + }); $('#toggleitems').click( function() { - $('#toggleitems').text() === 'Show local items only' ? $('#toggleitems').text("Show items in all libraries") : $('#toggleitems').text("Show local items only"); + $('#toggleitems').text($('#toggleitems').text() === 'Show local items only' ? 'Show items in all libraries' : 'Show local items only'); $('.branch_specific').toggle(); $('.all').toggle(); $('ul[class*="_loop_items"] li').each( function() { @@ -842,6 +847,13 @@ $(this).toggle(); } }); + + $(this).toggleClass('show-local-items show-all-items'); + if ($(this).hasClass('show-local-items')) { + Cookies.set("show_local_items", 'all', { path: '/', sameSite: 'Lax' }); + } else { + Cookies.set("show_local_items", 'local', { path: '/', sameSite: 'Lax' }); + } }); [% END %] [% IF SEARCH_RESULTS %] -- 2.39.2