The patron search page can be annoying because it never remembers where you left off. If I click a letter to browse by last name, follow a link, and then back up, the page doesn't remember that I was in the middle of a search. There are a lot of aspects which can be improved, but I have a patch which will address the specific case of the first letter search ("Browse by last name").
Created attachment 117009 [details] [review] Bug 27725: Use JavaScript to set history state during patron search This patch modifies the patron search page so that clicks on the "Browse by last name" letters add an entry to the browser history, allowing the user to click back and forth from results while preserving their search. To test, apply the patch and go to Patrons in the staff interface. - Click one of the "Browse by last name" letters. - The table of search results should load the correct data. - In the browser's location bar you should see a query string added to the URL, e.g. /cgi-bin/koha/members/members-home.pl?firstletter=Q - Click another letter. - Click the back button. You should be returned to the search results for your first letter choice. - Clicking the forward button should work correctly as well. - Other patron searches (header search, sidebar search) should continue to work as expected.
I like this! The only place it doesn't work is when a letter only has one patron. For example in koha-testing-docker with the letter O. In that case the first time you click on the letter it doesn't give a list of results, it goes straight to the patron. When you press the back button it quickly goes back to the list and then the patron page is loaded again. Not sure whether this can be fixed, or the likelihood of a normal library only having one patron for a letter. I think it would be better to list patrons even if there is only one result, rather than the back button not working as expected - not sure what others think though!
Created attachment 117123 [details] [review] Bug 27725: Use JavaScript to set history state during patron search This patch modifies the patron search page so that clicks on the "Browse by last name" letters add an entry to the browser history, allowing the user to click back and forth from results while preserving their search. To test, apply the patch and go to Patrons in the staff interface. - Click one of the "Browse by last name" letters. - The table of search results should load the correct data. - In the browser's location bar you should see a query string added to the URL, e.g. /cgi-bin/koha/members/members-home.pl?firstletter=Q - Click another letter. - Click the back button. You should be returned to the search results for your first letter choice. - Clicking the forward button should work correctly as well. - Other patron searches (header search, sidebar search) should continue to work as expected. EDIT: Clear single-letter querystring history item if only one result was returned.
This now works if there is only one result. Thanks for updating to address that behaviour! However, pressing the back button after multiple results for a letter now results in: - the URL changing to members-home.pl - the page remaining with "Patrons found for: begins with 'D'" - the current list of results remaining (D used in this example)
(In reply to David Nind from comment #4) > - the page remaining with "Patrons found for: begins with 'D'" This is a bug in master.
Hi Owen. I've finally had another go at this one. For some reason the forward button no longer works (after using the back button). I tested this in Firefox and Google Chrome (latest versions on Ubuntu 18.04). David
I also cannot get the forward button to work after using the back button. Also, if I click "A", then "B" then "C", then "D" it takes me to each of those pages correctly. But if I start pressing the back button I can go back to "C" but no further. If I try to go back any further I see the 'Processing...' box for a split second but noting happens. I am testing in Chrome and FF on MacOS.
Created attachment 123881 [details] [review] Bug 27725: Use JavaScript to set history state during patron search This patch modifies the patron search page so that clicks on the "Browse by last name" letters add an entry to the browser history, allowing the user to click back and forth from results while preserving their search. To test, apply the patch and go to Patrons in the staff interface. - Click one of the "Browse by last name" letters. - The table of search results should load the correct data. - In the browser's location bar you should see a query string added to the URL, e.g. /cgi-bin/koha/members/members-home.pl?firstletter=Q - Click another letter. - Click the back button. You should be returned to the search results for your first letter choice. - Clicking the forward button should work correctly as well. - Other patron searches (header search, sidebar search) should continue to work as expected. EDIT: Clear single-letter querystring history item if only one result was returned. EDIT 2: Fixed handling of history state changes so that forward and back buttons work correctly.
Created attachment 123913 [details] [review] Bug 27725: Use JavaScript to set history state during patron search This patch modifies the patron search page so that clicks on the "Browse by last name" letters add an entry to the browser history, allowing the user to click back and forth from results while preserving their search. To test, apply the patch and go to Patrons in the staff interface. - Click one of the "Browse by last name" letters. - The table of search results should load the correct data. - In the browser's location bar you should see a query string added to the URL, e.g. /cgi-bin/koha/members/members-home.pl?firstletter=Q - Click another letter. - Click the back button. You should be returned to the search results for your first letter choice. - Clicking the forward button should work correctly as well. - Other patron searches (header search, sidebar search) should continue to work as expected. EDIT: Clear single-letter querystring history item if only one result was returned. EDIT 2: Fixed handling of history state changes so that forward and back buttons work correctly. Signed-off-by: David Nind <david@davidnind.com>
Testing notes: - Tested using Firefox 91 and Google Chrome 91.0.4472.114 on Ubuntu 18.04 (64 bit) - Back and forward buttons work and display previous results - everything else seems to work as expected
Created attachment 125683 [details] [review] Bug 27725: Use JavaScript to set history state during patron search This patch modifies the patron search page so that clicks on the "Browse by last name" letters add an entry to the browser history, allowing the user to click back and forth from results while preserving their search. To test, apply the patch and go to Patrons in the staff interface. - Click one of the "Browse by last name" letters. - The table of search results should load the correct data. - In the browser's location bar you should see a query string added to the URL, e.g. /cgi-bin/koha/members/members-home.pl?firstletter=Q - Click another letter. - Click the back button. You should be returned to the search results for your first letter choice. - Clicking the forward button should work correctly as well. - Other patron searches (header search, sidebar search) should continue to work as expected. EDIT: Clear single-letter querystring history item if only one result was returned. EDIT 2: Fixed handling of history state changes so that forward and back buttons work correctly. Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Nice improvement!
Regression found: if you are using the patron search in the header, the search is not triggered.
Created attachment 125821 [details] [review] Bug 27725: (follow-up) Remove code for clearing search results This patch removes code which cleared search results if there was no first-letter search. It was unnecessary for the letter search functionality and made all other searches fail.
Patches will be squashed when pushed.
Pushed to master for 21.11, thanks to everybody involved!