From 1c267a4cb9b2ecac91b48b719bc83b514e6e16e3 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Thu, 1 Apr 2021 22:51:07 +0000 Subject: [PATCH] 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 Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart (cherry picked from commit 5787203a708429bfb746dfa16cfa6fee75a8714a) Signed-off-by: Fridolin Somers (cherry picked from commit 9e4388038350e2651dbc4aaa0c782503b83dc71c) Signed-off-by: Andrew Fuerste-Henry --- koha-tmpl/intranet-tmpl/js/browser.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/js/browser.js b/koha-tmpl/intranet-tmpl/js/browser.js index 2b9ee2f9db..a2c338d3d2 100644 --- a/koha-tmpl/intranet-tmpl/js/browser.js +++ b/koha-tmpl/intranet-tmpl/js/browser.js @@ -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 = ''; } else { prevbutton = ''; } - if (current_search.offset + me.curPos == current_search.total) { + if (parseInt(current_search.offset) + me.curPos == current_search.total) { nextbutton = ''; } else { nextbutton = ''; -- 2.39.5