Description
Magnus Enger
2015-06-03 13:03:55 UTC
I'd love to see that as it would also help in support. Being able to send an item search link to another staff member or the support team would be very helpful. Lisette Created attachment 164962 [details] [review] Bug 14322: Add button to copy link to an item search This work in progress patch adds a button to copy a url with all the parameters for an item search. The button currently works to copy a url with all the item search parameters url encoded, but the url returns 500.To make it work itemsearch.pl needs some updates to handle when the url parameter shareable=1, then it should process all the prameters from the url. Test plan: 1. Apply patch 2. Do an item search 3. On the results page see a new 'Copy shareable link' button 4. Click the button and confirm that you can paste a url with all parameters from the form url encoded 5. Paste the url in the browser and notice you get a 500 error :( Posting this patch for feedback. itemsearch.pl overrides the form submit button and gets an array of objects for all the parameters. This patch uses the same code that processes the form inputs into an array of objects, which is used in the ajax call to update the #results dataTable. It takes that array of parameters and uses jquery to parameterize it into a url encoded string. I think the remaining changes should be pretty minimal the encoded url is just a different way of representing the same data it already processes with the ajax call. Created attachment 168084 [details] [review] Bug 14322: Add button to copy link to an item search This work in progress patch adds a button to copy a url with all the parameters for an item search. The button currently works to copy a url with all the item search parameters url encoded, but the url returns 500. To make it work itemsearch.pl needs some updates to handle when the url parameter format=shareable, then it should handle authentication process all the prameters from the url. It would be really cool to also parameterize the state of the data table so the link could go straight to a filtered sorted result. Test plan: 1. Apply patch 2. Do an item search 3. On the results page see a new 'Copy shareable link' button 4. Click the button and confirm that you can paste a url with all parameters from the form url encoded 5. Paste the url in the browser and notice you get a 500 error :( Hey, giving my opinion here. As we have many datatables loaded by Ajax in all of Koha, I would propose we at least first consider looking at this problem at a lower layer level, i.e. try to find a way to make it possible to share any Ajax-based table state, instead of just the item search table specifically. An example of this is the patron table, ILL table, etc. I found this blog post regarding deep-linking in datatables: https://datatables.net/blog/2017/deep-linking I've not had the time to look into it myself, and it may very well not be the solution here, but at first glance it does look promising. The idea is, if we're able to implement this functionality at the datatables level, then theoretically any table may optionally present a "share table/search" button. Apologies if this input is not the most helpful, and it's just my opinion, but I'd personally much prefer to at least have an attempt at a more abstract way of tackling the issue here. Thanks Pedro! Appreciate the feedback and helpful link about deep linking to datatables. I agree that it would be ideal if the shareable link also contains the state of the table. I look at including the datatable state as a secondary issue only because the shareable link button first has to get all the parameters from the search form. And the perl code has to know how it should process the parameters from the url. Since the forms vary from page to page I think the implementation on the first part will vary. Based on the link you shared I think parametrizing the state of a data table could be generalized to work on any data table and then added on the end of the shareable link. I started thinking one solution could be to use the url parameters to actually populate the form and then trigger a form submission. Then the parameters would be processed the same way they currently are, and it would make it easier for the user to modify the search too. Created attachment 168768 [details] [review] Bug 14322: Add shareable link button to item search This work in progress patch adds a button to copy a link to an item search. I fixed the 500 issue, so now if you paste the url it fills the first two field sets in the item search form. Posting progress for feedback. Test plan: 1. Apply patch 2. Do an item search using only the first two field sets 3. Include 'is and 'is not' 4. On the results page see a new 'Copy shareable link' button 5. Click the button to copy the url and paste in the browser 6. Notice the first two field sets are filled as you would expect 7. Needs more work in the template to make the other field sets work Created attachment 168863 [details] [review] Bug 14322: Add shareable link button to item search This work in progress patch add a 'Copy shareable link' button to the item search results page. If you paste the link in the browser the item search form will be prefilled. Currently this works for all fields on the item search page except for fields added by the user with the '+ New field button' Test plan: 1. Apply patch 2. Try some item searches (except for ones using the '+ New field' button) 3. On the results page click the 'Copy shareable link' button 4. Paste the link into the browser and hit enter 5. Notice the item searhc form is filled out as you did earlier 6. Click 'Search' and confirm the results are as you would expect 7. Click 'Edit search', modify the search and search again 8. Test the 'Copy shareable link' button again TODO: add support for fields added with the '+ New field' button Created attachment 169029 [details] [review] Bug 14322: Add shareable link button to item search This patch adds a 'Copy shareable link' button to the item search results page. When pasted into the browser the item search form will be prefilled. The item search form submission still gets it's parameters from the form. Test plan: 1. Apply patch 2. Try some item searches (try searches using the '+ New field' button too) 3. On the results page click the 'Copy shareable link' button 4. Paste the link into the browser and hit enter 5. Notice the item search form is filled out exactly as you did earlier 6. Click 'Search' and confirm the results are as you would expect 7. Click 'Edit search', modify the search and search again 8. Test the 'Copy shareable link' button again 9. Test pasting the example link below 10. With default ktd data the search will return one result for: Intermediate Perl / Schwartz, Randal L. http://localhost:8081/cgi-bin/koha/catalogue/itemsearch.pl?homebranch_op=%3D&homebranch=CPL&holdingbranch_op=%3D&holdingbranch=CPL&location_op=%3D&location=GEN&itype_op=%3D&itype=BK&ccode_op=%3D&ccode=REF¬forloan_op=!%3D¬forloan=1&itemlost_op=!%3D&itemlost=1&withdrawn_op=!%3D&withdrawn=1&damaged_op=!%3D&damaged=1&onloan=&f=publishercode&op=like&q=O'Reilly%2C&c=and&f=publicationyear&op=like&q=2006&c=and&f=title&op=not%20like&q=Javascript%20%3A&c=and&f=author&op=not%20like&q=Carlson%2C%20Lucas.&itemcallnumber_from=&itemcallnumber_to=&issues_op=%3E&issues=&datelastborrowed_op=%3E&datelastborrowed=&format=shareable Created attachment 169033 [details] [review] Bug 14322: Add shareable link button to item search This patch adds a 'Copy shareable link' button to the item search results page. When pasted into the browser the item search form will be prefilled. The item search form submission still gets it's parameters from the form. Test plan: 1. Apply patch 2. Try some item searches (try searches using the '+ New field' button too) 3. On the results page click the 'Copy shareable link' button 4. Paste the link into the browser and hit enter 5. Notice the item search form is filled out exactly as you did earlier 6. Click 'Search' and confirm the results are as you would expect 7. Click 'Edit search', modify the search and search again 8. Test the 'Copy shareable link' button again 9. Test pasting the example link below 10. With default ktd data the search will return one result for: Intermediate Perl / Schwartz, Randal L. http://localhost:8081/cgi-bin/koha/catalogue/itemsearch.pl?homebranch_op=%3D&homebranch=CPL&holdingbranch_op=%3D&holdingbranch=CPL&location_op=%3D&location=GEN&itype_op=%3D&itype=BK&ccode_op=%3D&ccode=REF¬forloan_op=!%3D¬forloan=1&itemlost_op=!%3D&itemlost=1&withdrawn_op=!%3D&withdrawn=1&damaged_op=!%3D&damaged=1&onloan=&f=publishercode&op=like&q=O'Reilly%2C&c=and&f=publicationyear&op=like&q=2006&c=and&f=title&op=not%20like&q=Javascript%20%3A&c=and&f=author&op=not%20like&q=Carlson%2C%20Lucas.&itemcallnumber_from=&itemcallnumber_to=&issues_op=%3E&issues=&datelastborrowed_op=%3E&datelastborrowed=&format=shareable Signed-off-by: David Nind <david@davidnind.com> One style change needed: The new button should have the class "btn-default" instead of "btn-secondary" Is it just me or does it feel unexpected that the link doesn't take me to the search results directly? Thanks Owen. I appreciated the feedback and will update the button style. I will try to make an update that would load the results page first too. (In reply to Brendan Lawlor from comment #13) > Thanks Owen. I appreciated the feedback and will update the button style. > > I will try to make an update that would load the results page first too. Changing status. Created attachment 169304 [details] [review] Bug 14322: Add shareable link button to item search This patch adds a 'Copy shareable link' button to the item search results page. When pasted into the browser the item search form will be prefilled. The item search form submission still gets it's parameters from the form. Test plan: 1. Apply patch 2. Try some item searches (try searches using the '+ New field' button too) 3. On the results page click the 'Copy shareable link' button 4. Paste the link into the browser and hit enter 5. Notice the item search form is filled out exactly as you did earlier 6. Click 'Search' and confirm the results are as you would expect 7. Click 'Edit search', modify the search and search again 8. Test the 'Copy shareable link' button again 9. Test pasting the example link below 10. With default ktd data the search will return one result for: Intermediate Perl / Schwartz, Randal L. http://localhost:8081/cgi-bin/koha/catalogue/itemsearch.pl?homebranch_op=%3D&homebranch=CPL&holdingbranch_op=%3D&holdingbranch=CPL&location_op=%3D&location=GEN&itype_op=%3D&itype=BK&ccode_op=%3D&ccode=REF¬forloan_op=!%3D¬forloan=1&itemlost_op=!%3D&itemlost=1&withdrawn_op=!%3D&withdrawn=1&damaged_op=!%3D&damaged=1&onloan=&f=publishercode&op=like&q=O'Reilly%2C&c=and&f=publicationyear&op=like&q=2006&c=and&f=title&op=not%20like&q=Javascript%20%3A&c=and&f=author&op=not%20like&q=Carlson%2C%20Lucas.&itemcallnumber_from=&itemcallnumber_to=&issues_op=%3E&issues=&datelastborrowed_op=%3E&datelastborrowed=&format=shareable Created attachment 169305 [details] [review] Bug 14322: (follow-up) update shareable link button style Created attachment 169306 [details] [review] Bug 14322: (follow-up) make shareable link load results immediately Hi Brendan. Thanks for all your work on this! It looked like everything was all working as expected, however I came across a situation using the + New field: - Home library is: Centerville - Barcode is 39999% - AND Title is %perl% - Search (6 results) - Copy shareable link - Paste the link in a new tab - Get 321 results - When you edit the search the AND is changed to an OR Shareable link: http://127.0.0.1:8081/cgi-bin/koha/catalogue/itemsearch.pl?homebranch_op=%3D&homebranch=CPL&holdingbranch_op=%3D&location_op=%3D&itype_op=%3D&ccode_op=%3D¬forloan_op=%3D&itemlost_op=%3D&withdrawn_op=%3D&damaged_op=%3D&onloan=&f=barcode&op=like&q=3999%25&c=and&f=title&op=like&q=%25perl%25&itemcallnumber_from=&itemcallnumber_to=&issues_op=%3E&issues=&datelastborrowed_op=%3E&datelastborrowed=&format=shareable David Created attachment 169948 [details] [review] Bug 14322: Add shareable link button to item search This patch adds a 'Copy shareable link' button to the item search results page. When pasted into the browser the item search form will be prefilled. The item search form submission still gets it's parameters from the form. Test plan: 1. Apply patch 2. Try some item searches (try searches using the '+ New field' button too) 3. On the results page click the 'Copy shareable link' button 4. Paste the link into the browser and hit enter 5. Notice the item search form is filled out exactly as you did earlier 6. Click 'Search' and confirm the results are as you would expect 7. Click 'Edit search', modify the search and search again 8. Test the 'Copy shareable link' button again 9. Test pasting the example link below 10. With default ktd data the search will return one result for: Intermediate Perl / Schwartz, Randal L. http://localhost:8081/cgi-bin/koha/catalogue/itemsearch.pl?homebranch_op=%3D&homebranch=CPL&holdingbranch_op=%3D&holdingbranch=CPL&location_op=%3D&location=GEN&itype_op=%3D&itype=BK&ccode_op=%3D&ccode=REF¬forloan_op=!%3D¬forloan=1&itemlost_op=!%3D&itemlost=1&withdrawn_op=!%3D&withdrawn=1&damaged_op=!%3D&damaged=1&onloan=&f=publishercode&op=like&q=O'Reilly%2C&c=and&f=publicationyear&op=like&q=2006&c=and&f=title&op=not%20like&q=Javascript%20%3A&c=and&f=author&op=not%20like&q=Carlson%2C%20Lucas.&itemcallnumber_from=&itemcallnumber_to=&issues_op=%3E&issues=&datelastborrowed_op=%3E&datelastborrowed=&format=shareable Sponsored-by: CLAMS Created attachment 169949 [details] [review] Bug 14322: (follow-up) update shareable link button style Created attachment 169950 [details] [review] Bug 14322: (follow-up) make shareable link load results immediately Created attachment 169951 [details] [review] Bug 14322: (follow-up) add check for single logical operator param Created attachment 169952 [details] [review] Bug 14322: (follow-up) Perl tidy (In reply to David Nind from comment #18) > It looked like everything was all working as expected, however I came across > a situation using the + New field: > - Home library is: Centerville > - Barcode is 39999% > - AND Title is %perl% > - Search (6 results) > - Copy shareable link > - Paste the link in a new tab > - Get 321 results > - When you edit the search the AND is changed to an OR Thanks, David, for testing and spotting that bug! This was caused because of assuming getting the 'c' param would return an array. When there is only a single 'c' param it's just a string, so I added a check for that too. Created attachment 169969 [details] [review] Bug 14322: Add shareable link button to item search This patch adds a 'Copy shareable link' button to the item search results page. When pasted into the browser the item search form will be prefilled. The item search form submission still gets it's parameters from the form. Test plan: 1. Apply patch 2. Try some item searches (try searches using the '+ New field' button too) 3. On the results page click the 'Copy shareable link' button 4. Paste the link into the browser and hit enter 5. Notice the item search form is filled out exactly as you did earlier 6. Click 'Search' and confirm the results are as you would expect 7. Click 'Edit search', modify the search and search again 8. Test the 'Copy shareable link' button again 9. Test pasting the example link below 10. With default ktd data the search will return one result for: Intermediate Perl / Schwartz, Randal L. http://localhost:8081/cgi-bin/koha/catalogue/itemsearch.pl?homebranch_op=%3D&homebranch=CPL&holdingbranch_op=%3D&holdingbranch=CPL&location_op=%3D&location=GEN&itype_op=%3D&itype=BK&ccode_op=%3D&ccode=REF¬forloan_op=!%3D¬forloan=1&itemlost_op=!%3D&itemlost=1&withdrawn_op=!%3D&withdrawn=1&damaged_op=!%3D&damaged=1&onloan=&f=publishercode&op=like&q=O'Reilly%2C&c=and&f=publicationyear&op=like&q=2006&c=and&f=title&op=not%20like&q=Javascript%20%3A&c=and&f=author&op=not%20like&q=Carlson%2C%20Lucas.&itemcallnumber_from=&itemcallnumber_to=&issues_op=%3E&issues=&datelastborrowed_op=%3E&datelastborrowed=&format=shareable Sponsored-by: CLAMS Signed-off-by: David Nind <david@davidnind.com> Created attachment 169970 [details] [review] Bug 14322: (follow-up) update shareable link button style Signed-off-by: David Nind <david@davidnind.com> Created attachment 169971 [details] [review] Bug 14322: (follow-up) make shareable link load results immediately Signed-off-by: David Nind <david@davidnind.com> Created attachment 169972 [details] [review] Bug 14322: (follow-up) add check for single logical operator param Signed-off-by: David Nind <david@davidnind.com> Created attachment 169973 [details] [review] Bug 14322: (follow-up) Perl tidy Signed-off-by: David Nind <david@davidnind.com> Created attachment 170347 [details] [review] Bug 14322: Add shareable link button to item search This patch adds a 'Copy shareable link' button to the item search results page. When pasted into the browser the item search form will be prefilled. The item search form submission still gets it's parameters from the form. Test plan: 1. Apply patch 2. Try some item searches (try searches using the '+ New field' button too) 3. On the results page click the 'Copy shareable link' button 4. Paste the link into the browser and hit enter 5. Notice the item search form is filled out exactly as you did earlier 6. Click 'Search' and confirm the results are as you would expect 7. Click 'Edit search', modify the search and search again 8. Test the 'Copy shareable link' button again 9. Test pasting the example link below 10. With default ktd data the search will return one result for: Intermediate Perl / Schwartz, Randal L. http://localhost:8081/cgi-bin/koha/catalogue/itemsearch.pl?homebranch_op=%3D&homebranch=CPL&holdingbranch_op=%3D&holdingbranch=CPL&location_op=%3D&location=GEN&itype_op=%3D&itype=BK&ccode_op=%3D&ccode=REF¬forloan_op=!%3D¬forloan=1&itemlost_op=!%3D&itemlost=1&withdrawn_op=!%3D&withdrawn=1&damaged_op=!%3D&damaged=1&onloan=&f=publishercode&op=like&q=O'Reilly%2C&c=and&f=publicationyear&op=like&q=2006&c=and&f=title&op=not%20like&q=Javascript%20%3A&c=and&f=author&op=not%20like&q=Carlson%2C%20Lucas.&itemcallnumber_from=&itemcallnumber_to=&issues_op=%3E&issues=&datelastborrowed_op=%3E&datelastborrowed=&format=shareable Sponsored-by: CLAMS Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> Created attachment 170348 [details] [review] Bug 14322: (follow-up) update shareable link button style Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> Created attachment 170349 [details] [review] Bug 14322: (follow-up) make shareable link load results immediately Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> Created attachment 170350 [details] [review] Bug 14322: (follow-up) add check for single logical operator param Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> Created attachment 170351 [details] [review] Bug 14322: (follow-up) Perl tidy Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> Created attachment 170352 [details] [review] Bug 14322: (QA follow-up) Tidy itemsearch.tt 1) Translatability Please fix the "Copied!" string here to make it translatable. + $(this).tooltip({trigger: 'manual', title: 'Copied!'}).tooltip('show'); You can attach the follow-up patch here and reset to Passed QA if the status has changed already. Created attachment 170721 [details] [review] Bug 14322: Add shareable link button to item search This patch adds a 'Copy shareable link' button to the item search results page. When pasted into the browser the item search form will be prefilled. The item search form submission still gets it's parameters from the form. Test plan: 1. Apply patch 2. Try some item searches (try searches using the '+ New field' button too) 3. On the results page click the 'Copy shareable link' button 4. Paste the link into the browser and hit enter 5. Notice the item search form is filled out exactly as you did earlier 6. Click 'Search' and confirm the results are as you would expect 7. Click 'Edit search', modify the search and search again 8. Test the 'Copy shareable link' button again 9. Test pasting the example link below 10. With default ktd data the search will return one result for: Intermediate Perl / Schwartz, Randal L. http://localhost:8081/cgi-bin/koha/catalogue/itemsearch.pl?homebranch_op=%3D&homebranch=CPL&holdingbranch_op=%3D&holdingbranch=CPL&location_op=%3D&location=GEN&itype_op=%3D&itype=BK&ccode_op=%3D&ccode=REF¬forloan_op=!%3D¬forloan=1&itemlost_op=!%3D&itemlost=1&withdrawn_op=!%3D&withdrawn=1&damaged_op=!%3D&damaged=1&onloan=&f=publishercode&op=like&q=O'Reilly%2C&c=and&f=publicationyear&op=like&q=2006&c=and&f=title&op=not%20like&q=Javascript%20%3A&c=and&f=author&op=not%20like&q=Carlson%2C%20Lucas.&itemcallnumber_from=&itemcallnumber_to=&issues_op=%3E&issues=&datelastborrowed_op=%3E&datelastborrowed=&format=shareable Sponsored-by: CLAMS Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> Current status: Passed QA Created attachment 170722 [details] [review] Bug 14322: (follow-up) update shareable link button style Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> Created attachment 170723 [details] [review] Bug 14322: (follow-up) make shareable link load results immediately Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> Created attachment 170724 [details] [review] Bug 14322: (follow-up) add check for single logical operator param Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> Created attachment 170725 [details] [review] Bug 14322: (follow-up) Perl tidy Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> Created attachment 170726 [details] [review] Bug 14322: (QA follow-up) Tidy itemsearch.tt Created attachment 170727 [details] [review] Bug 14322: (follow-up) make copied tooltip translatable Thanks! I already had this on my branch today, just added the follow-up on top. Pushed for 24.11! Well done everyone, thank you! Missed it before pushing: Translatable strings needs to always be enclosed in double quotes. This is to prevent translators from breaking Javascript accidentally. Fixed in a tiny follow-up. Guess I was the one who reported this ~9 years ago. Many, many thanks to everyone involved in fixing it! :-) (In reply to Katrin Fischer from comment #46) > Missed it before pushing: Translatable strings needs to always be enclosed > in double quotes. This is to prevent translators from breaking Javascript > accidentally. Fixed in a tiny follow-up. This is really good to know. Thanks Katrin! Also Thanks to Magnus for putting the idea out there. It was fun to work on and I learned a lot in the process. This is so much changes to impact only one table. Additionally we cannot filter after you have got the result and have the URL updated. We should absolutely promote a global solution like what bug 27467 is suggesting, that will impact ALL tables in Koha. (In reply to Jonathan Druart from comment #49) > This is so much changes to impact only one table. Additionally we cannot > filter after you have got the result and have the URL updated. > > We should absolutely promote a global solution like what bug 27467 is > suggesting, that will impact ALL tables in Koha. Thanks for the feedback. This is a valid point that it would be best to have a global solution to link to all tables in Koha. I am interested in learning about possible solutions to acheive this Most of the changes in this patch are to the template, in order to fill the form inputs from the url. I think those changes would still be necessary for the 'Edit search' button to work. It's similar to how the 'edit this search' link works from the advanced search results. It sends url parameters to search.pl and the form is populated. In Item search it's a little different because it's all one page, and the 'Edit search' button just shows the form that the user previously filled with javascript. With the datatables deep link solution #2 in bug 27467, I think we could add filtering and sort parameters to the shareable url that should be able to work for all datatables. Pedro shared this article about deeplinking earlier: https://datatables.net/blog/2017/deep-linking?order=[[3,%22asc%22]] We should discuss all this on bug 27467. You will find the exact same link there ;) spoiler: deepLink is not what we want. |