Bug 28074 - Browse controls on staff detail pages are sometimes weird
Summary: Browse controls on staff detail pages are sometimes weird
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Lucas Gass
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-01 22:49 UTC by Lucas Gass
Modified: 2021-04-24 17:19 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Text to go in the release notes:
Version(s) released in:
21.05.00,20.11.05,20.05.11


Attachments
Bug 28074: Make current_search.offset an integer instead of string (3.75 KB, patch)
2021-04-01 22:54 UTC, Lucas Gass
Details | Diff | Splinter Review
Bug 28074: Make current_search.offset an integer instead of string (3.82 KB, patch)
2021-04-02 13:22 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 28074: Make current_search.offset an integer instead of string (3.87 KB, patch)
2021-04-03 14:06 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Lucas Gass 2021-04-01 22:49:03 UTC
The browse control feature doesn't work quite right in the OPAC detail. 

1. If you 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.

This is because in js/browser.js, if you look at the current_search Object and specifically at current_search.offset you will see that current_search.offset is a string.

We try to do calculations with that variable and JavaScript performs string concatenation instead of addtion. 

For example:

current_search.offset + me.curPos == current_search.total

When the offset is '1' and we add it to 0, the result is 10. Therefore if the offset is the first and the total is 10, it thinks we are on the last result (10) and doesn't let use move forward. 


Converting current_search.offset to an integer solves the problem.
Comment 1 Lucas Gass 2021-04-01 22:53:18 UTC
When I said OPAC detail, I meant staff detail
Comment 2 Lucas Gass 2021-04-01 22:54:05 UTC
Created attachment 119090 [details] [review]
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
Comment 3 Owen Leonard 2021-04-02 13:22:15 UTC
Created attachment 119122 [details] [review]
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>
Comment 4 Katrin Fischer 2021-04-03 14:06:27 UTC
Created attachment 119154 [details] [review]
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>
Comment 5 Jonathan Druart 2021-04-06 14:00:03 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 6 Fridolin Somers 2021-04-15 10:43:27 UTC
Pushed to 20.11.x for 20.11.05
Comment 7 Andrew Fuerste-Henry 2021-04-24 17:01:57 UTC
Pushed to 20.05.x for 20.05.11
Comment 8 Victor Grousset/tuxayo 2021-04-24 17:19:38 UTC
Not backported to oldoldstable (19.11.x). Feel free to ask if it's needed.