Bug 28074: Make current_search.offset an integer instead of string

To test:
1. Do a search with 3-4 results, go to the record and use the browse
   controls, when you get to the last record if you attempt to go to the
   'next' you'll end up on a page which says 'record not found.'
2. Do a search with exactly 10 results. Click on the first record, the
   'next' arrow is not a link, you cannot move to the next result.
3. Apply patch
4. Repeat steps 1-2 and the problems should be gone.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Lucas Gass 2021-04-01 22:51:07 +00:00 committed by Jonathan Druart
parent 8a6bb8c6cd
commit 5787203a70
1 changed files with 6 additions and 6 deletions

View File

@ -42,9 +42,9 @@ KOHA.browser = function (searchid, biblionumber) {
me.create = function (offset, query, limit, sort, newresults, total) {
if (current_search) {
if (offset === current_search.offset - newresults.length) {
if (offset === parseInt(current_search.offset) - newresults.length) {
current_search.results = newresults.concat(current_search.results);
} else if (searchOffset = current_search.offset + newresults.length) {
} else if (searchOffset = parseInt(current_search.offset) + newresults.length) {
current_search.results = current_search.results.concat(newresults);
} else {
delete current_search;
@ -73,10 +73,10 @@ KOHA.browser = function (searchid, biblionumber) {
me.show = function () {
if (current_search) {
me.curPos = $.inArray(biblionumber, current_search.results);
if ( current_search.offset + me.curPos <= current_search.pagelen ) { // First page
if ( parseInt(current_search.offset ) + me.curPos <= current_search.pagelen ) { // First page
me.offset = 0;
} else {
me.offset = current_search.offset - 1;
me.offset = parseInt(current_search.offset) - 1;
}
$(document).ready(function () {
@ -84,12 +84,12 @@ KOHA.browser = function (searchid, biblionumber) {
var searchURL = '/cgi-bin/koha/catalogue/search.pl?' + decodeURIComponent(current_search.query) + '&limit=' + decodeURIComponent(current_search.limit) + '&sort_by=' + current_search.sort + '&searchid=' + me.searchid + '&offset=' + me.offset;
var prevbutton;
var nextbutton;
if (me.curPos === 0 && current_search.offset === 1) {
if (me.curPos === 0 && parseInt(current_search.offset) === 1) {
prevbutton = '<span id="browse-previous" class="browse-button" title="' + __("Previous") + '"><i class="fa fa-arrow-left"></i></span>';
} else {
prevbutton = '<a href="#" id="browse-previous" class="browse-button" title="' + __("Previous") + '"><i class="fa fa-arrow-left"></i></a>';
}
if (current_search.offset + me.curPos == current_search.total) {
if (parseInt(current_search.offset) + me.curPos == current_search.total) {
nextbutton = '<span id="browse-next" class="browse-button" title="' + __("Next") + '"><i class="fa fa-arrow-right"></i></span>';
} else {
nextbutton = '<a href="#" id="browse-next" class="browse-button" title="' + __("Next") + '"><i class="fa fa-arrow-right"></i></a>';