From 51dbb84a78e7ad833ab2ce6104ed54954ded6835 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 31 Mar 2020 16:39:12 +0200 Subject: [PATCH] Bug 25027: Use localStorage instead of sessionStorage for results browser Staff side, when a search a done and a result clicked, a browser appears on the left, to navigate between the different results. We use sessionStorage to know the list of biblionumber from the result. As sessionStorage is only for the current tab, we do some ugly things, to catch the click events, then open the new tab, attach it to the current window, and put the focus back on the result list. We really should not do that, and let the user decide what they want to do with their clicks! To do so, let use the correct storage, localStorage, and have the results shared between the windows. We may need to clear that at some point, isn't it? Test plan: Launch a search, click result (left or middle), confirm you see the browser and that the window/tab opened like any other websites (depending on your web browser settings). Signed-off-by: Owen Leonard Signed-off-by: Nick Clemens Signed-off-by: Martin Renvoize --- koha-tmpl/intranet-tmpl/js/browser.js | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/js/browser.js b/koha-tmpl/intranet-tmpl/js/browser.js index 5763c7c3e6..120d710a2c 100644 --- a/koha-tmpl/intranet-tmpl/js/browser.js +++ b/koha-tmpl/intranet-tmpl/js/browser.js @@ -11,7 +11,7 @@ KOHA.browser = function (searchid, biblionumber) { } me.searchid = searchid; - var searches_stored = sessionStorage.getItem('searches'); + var searches_stored = localStorage.getItem('searches'); var current_search; var searches = {}; if ( searches_stored ) { @@ -62,24 +62,10 @@ KOHA.browser = function (searchid, biblionumber) { }; } searches[me.searchid] = current_search; - sessionStorage.setItem('searches', JSON.stringify(searches)); + localStorage.setItem('searches', JSON.stringify(searches)); $(document).ready(function () { - //FIXME It's not a good idea to modify the click events - $('#searchresults table tr a[href*="/detail.pl"]').on('click auxclick', function (ev) { - ev.preventDefault(); - }); - $('#searchresults table tr a[href*="/detail.pl"]').on('mousedown', function (ev) { - if ( ev.which == 2 || ev.which == 1 && ev.ctrlKey ) { - // Middle click or ctrl + click - ev.preventDefault(); - var newwindow = window.open( $(this).attr('href') + '&searchid=' + me.searchid, '_blank' ); - newwindow.blur(); - window.focus(); - } else if ( ev.which == 1 ) { - // Left click - ev.preventDefault(); - window.location = $(this).attr('href') + '&searchid=' + me.searchid; - } + $('#searchresults table tr a[href*="/detail.pl"]').each(function(){ + $(this).attr('href', $(this).attr('href') + '&searchid=' + me.searchid ); }); }); }; -- 2.39.5