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 <oleonard@myacpl.org>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Joy Nelson <joy@bywatersolutions.com>
(cherry picked from commit 0ac67146b9)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2020-03-31 16:39:12 +02:00 committed by Lucas Gass
parent 02cccad3cf
commit 86822a5bc5
1 changed files with 4 additions and 18 deletions

View File

@ -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 );
});
});
};