Bug 30325: (Bug 30098 follow-up) Fix broken patron search redirect when one result

Bug 30098 fixed patron search behavior when a later page has only 1 result, but broke the redirect when there is only a single result from search.

To test:
1 - Perform a patron search that returns 41 results, on koha-testing-docker, 'a' works
2 - Go to second page of results, works
3 - On third page you remain in results and are not redirected
4 - Perform a patron search that return only 1 result, name or cardnumber
5 - You get redirected to this patron page

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Fridolin Somers 2022-03-21 12:18:57 -10:00
parent 8fdfa80609
commit d1b2601b01

View file

@ -440,7 +440,7 @@
'data': aoData,
'success': function(json){
// redirect if there is only 1 result.
if ( json.aaData.length == 1 && aoData.iDisplayStart == 0 ) {
if ( json.iTotalDisplayRecords == 1 ) {
var borrowernumber = json.aaData[0].borrowernumber;
/* Overwrite history state of firstletter search since only one result was returned; This prevents a loop upon clicking back */
history.replaceState( {}, null, window.location.href.split("?" )[0]);