Bug 14322 - Add option to create a shareable link for item searches
Summary: Add option to create a shareable link for item searches
Status: Needs documenting
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Brendan Lawlor
QA Contact: Paul Derscheid
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-03 13:03 UTC by Magnus Enger
Modified: 2024-11-15 17:45 UTC (History)
18 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Medium patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This enhancement adds a 'Copy shareable link' button to item search results in the staff interface. Previously, the only way to share a search with colleagues was by detailing all the search parameters - and they would then need to manually add these to the item search form.
Version(s) released in:
24.11.00
Circulation function:


Attachments
Bug 14322: Add button to copy link to an item search (4.11 KB, patch)
2024-04-16 21:13 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 14322: Add button to copy link to an item search (5.00 KB, patch)
2024-06-25 15:42 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 14322: Add shareable link button to item search (4.03 KB, patch)
2024-07-10 20:33 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 14322: Add shareable link button to item search (12.87 KB, patch)
2024-07-11 19:13 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 14322: Add shareable link button to item search (16.63 KB, patch)
2024-07-15 20:54 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 14322: Add shareable link button to item search (16.68 KB, patch)
2024-07-16 02:21 UTC, David Nind
Details | Diff | Splinter Review
Bug 14322: Add shareable link button to item search (16.63 KB, patch)
2024-07-22 14:23 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 14322: (follow-up) update shareable link button style (1.09 KB, patch)
2024-07-22 14:23 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 14322: (follow-up) make shareable link load results immediately (1.09 KB, patch)
2024-07-22 14:23 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 14322: Add shareable link button to item search (16.65 KB, patch)
2024-08-01 14:12 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 14322: (follow-up) update shareable link button style (1.09 KB, patch)
2024-08-01 14:12 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 14322: (follow-up) make shareable link load results immediately (1.08 KB, patch)
2024-08-01 14:12 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 14322: (follow-up) add check for single logical operator param (1.06 KB, patch)
2024-08-01 14:12 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 14322: (follow-up) Perl tidy (3.97 KB, patch)
2024-08-01 14:12 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 14322: Add shareable link button to item search (16.69 KB, patch)
2024-08-02 01:44 UTC, David Nind
Details | Diff | Splinter Review
Bug 14322: (follow-up) update shareable link button style (1.13 KB, patch)
2024-08-02 01:44 UTC, David Nind
Details | Diff | Splinter Review
Bug 14322: (follow-up) make shareable link load results immediately (1.12 KB, patch)
2024-08-02 01:44 UTC, David Nind
Details | Diff | Splinter Review
Bug 14322: (follow-up) add check for single logical operator param (1.11 KB, patch)
2024-08-02 01:44 UTC, David Nind
Details | Diff | Splinter Review
Bug 14322: (follow-up) Perl tidy (4.02 KB, patch)
2024-08-02 01:45 UTC, David Nind
Details | Diff | Splinter Review
Bug 14322: Add shareable link button to item search (16.75 KB, patch)
2024-08-15 10:30 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 14322: (follow-up) update shareable link button style (1.19 KB, patch)
2024-08-15 10:30 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 14322: (follow-up) make shareable link load results immediately (1.18 KB, patch)
2024-08-15 10:30 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 14322: (follow-up) add check for single logical operator param (1.17 KB, patch)
2024-08-15 10:30 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 14322: (follow-up) Perl tidy (4.07 KB, patch)
2024-08-15 10:30 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 14322: (QA follow-up) Tidy itemsearch.tt (1.41 KB, patch)
2024-08-15 10:33 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 14322: Add shareable link button to item search (16.75 KB, patch)
2024-08-26 14:49 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 14322: (follow-up) update shareable link button style (1.19 KB, patch)
2024-08-26 14:50 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 14322: (follow-up) make shareable link load results immediately (1.18 KB, patch)
2024-08-26 14:50 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 14322: (follow-up) add check for single logical operator param (1.17 KB, patch)
2024-08-26 14:50 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 14322: (follow-up) Perl tidy (4.07 KB, patch)
2024-08-26 14:50 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 14322: (QA follow-up) Tidy itemsearch.tt (1.41 KB, patch)
2024-08-26 14:50 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 14322: (follow-up) make copied tooltip translatable (1.15 KB, patch)
2024-08-26 14:50 UTC, Brendan Lawlor
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Magnus Enger 2015-06-03 13:03:55 UTC
The new item search in the staff client is awesome, but a bit too AJAXy for my tastes. The main problem is that it is not possible to link to the results of a search. If you do a search and you want to show the results to a colleague, you have to explain what boxes to check, what to type where, what to select from what pulldown menus etc. If the search criteria were in the URL it could be done with simply copying and pasting the URL.
Comment 1 Katrin Fischer 2019-08-13 06:27:29 UTC
I'd love to see that as it would also help in support.
Comment 2 Lisette Scheer 2021-01-21 18:38:54 UTC
Being able to send an item search link to another staff member or the support team would be very helpful. 
Lisette
Comment 3 Brendan Lawlor 2024-04-16 21:13:07 UTC
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 :(
Comment 4 Brendan Lawlor 2024-04-16 21:26:28 UTC
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.
Comment 5 Brendan Lawlor 2024-06-25 15:42:29 UTC
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 :(
Comment 6 Pedro Amorim 2024-07-03 15:27:43 UTC
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.
Comment 7 Brendan Lawlor 2024-07-03 17:00:57 UTC
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.
Comment 8 Brendan Lawlor 2024-07-10 20:33:49 UTC
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
Comment 9 Brendan Lawlor 2024-07-11 19:13:13 UTC
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
Comment 10 Brendan Lawlor 2024-07-15 20:54:07 UTC
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&notforloan_op=!%3D&notforloan=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
Comment 11 David Nind 2024-07-16 02:21:13 UTC
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&notforloan_op=!%3D&notforloan=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>
Comment 12 Owen Leonard 2024-07-17 14:54:05 UTC
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?
Comment 13 Brendan Lawlor 2024-07-17 20:18:07 UTC
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.
Comment 14 Marcel de Rooy 2024-07-19 09:35:59 UTC
(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.
Comment 15 Brendan Lawlor 2024-07-22 14:23:49 UTC
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&notforloan_op=!%3D&notforloan=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
Comment 16 Brendan Lawlor 2024-07-22 14:23:52 UTC
Created attachment 169305 [details] [review]
Bug 14322: (follow-up) update shareable link button style
Comment 17 Brendan Lawlor 2024-07-22 14:23:55 UTC
Created attachment 169306 [details] [review]
Bug 14322: (follow-up) make shareable link load results immediately
Comment 18 David Nind 2024-07-22 20:46:05 UTC
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&notforloan_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
Comment 19 Brendan Lawlor 2024-08-01 14:12:21 UTC
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&notforloan_op=!%3D&notforloan=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
Comment 20 Brendan Lawlor 2024-08-01 14:12:24 UTC
Created attachment 169949 [details] [review]
Bug 14322: (follow-up) update shareable link button style
Comment 21 Brendan Lawlor 2024-08-01 14:12:27 UTC
Created attachment 169950 [details] [review]
Bug 14322: (follow-up) make shareable link load results immediately
Comment 22 Brendan Lawlor 2024-08-01 14:12:29 UTC
Created attachment 169951 [details] [review]
Bug 14322: (follow-up) add check for single logical operator param
Comment 23 Brendan Lawlor 2024-08-01 14:12:32 UTC
Created attachment 169952 [details] [review]
Bug 14322: (follow-up) Perl tidy
Comment 24 Brendan Lawlor 2024-08-01 14:18:59 UTC
(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.
Comment 25 David Nind 2024-08-02 01:44:44 UTC
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&notforloan_op=!%3D&notforloan=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>
Comment 26 David Nind 2024-08-02 01:44:48 UTC
Created attachment 169970 [details] [review]
Bug 14322: (follow-up) update shareable link button style

Signed-off-by: David Nind <david@davidnind.com>
Comment 27 David Nind 2024-08-02 01:44:52 UTC
Created attachment 169971 [details] [review]
Bug 14322: (follow-up) make shareable link load results immediately

Signed-off-by: David Nind <david@davidnind.com>
Comment 28 David Nind 2024-08-02 01:44:56 UTC
Created attachment 169972 [details] [review]
Bug 14322: (follow-up) add check for single logical operator param

Signed-off-by: David Nind <david@davidnind.com>
Comment 29 David Nind 2024-08-02 01:45:00 UTC
Created attachment 169973 [details] [review]
Bug 14322: (follow-up) Perl tidy

Signed-off-by: David Nind <david@davidnind.com>
Comment 30 Paul Derscheid 2024-08-15 10:30:46 UTC
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&notforloan_op=!%3D&notforloan=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>
Comment 31 Paul Derscheid 2024-08-15 10:30:49 UTC
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>
Comment 32 Paul Derscheid 2024-08-15 10:30:52 UTC
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>
Comment 33 Paul Derscheid 2024-08-15 10:30:55 UTC
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>
Comment 34 Paul Derscheid 2024-08-15 10:30:58 UTC
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>
Comment 35 Paul Derscheid 2024-08-15 10:33:35 UTC
Created attachment 170352 [details] [review]
Bug 14322: (QA follow-up) Tidy itemsearch.tt
Comment 36 Katrin Fischer 2024-08-26 08:27:14 UTC
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.
Comment 37 Brendan Lawlor 2024-08-26 14:49:57 UTC
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&notforloan_op=!%3D&notforloan=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
Comment 38 Brendan Lawlor 2024-08-26 14:50:00 UTC
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>
Comment 39 Brendan Lawlor 2024-08-26 14:50:03 UTC
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>
Comment 40 Brendan Lawlor 2024-08-26 14:50:06 UTC
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>
Comment 41 Brendan Lawlor 2024-08-26 14:50:08 UTC
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>
Comment 42 Brendan Lawlor 2024-08-26 14:50:11 UTC
Created attachment 170726 [details] [review]
Bug 14322: (QA follow-up) Tidy itemsearch.tt
Comment 43 Brendan Lawlor 2024-08-26 14:50:14 UTC
Created attachment 170727 [details] [review]
Bug 14322: (follow-up) make copied tooltip translatable
Comment 44 Katrin Fischer 2024-08-26 15:38:21 UTC
Thanks! I already had this on my branch today, just added the follow-up on top.
Comment 45 Katrin Fischer 2024-08-26 15:43:22 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 46 Katrin Fischer 2024-08-26 16:44:30 UTC
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.
Comment 47 Magnus Enger 2024-08-27 06:30:18 UTC
Guess I was the one who reported this ~9 years ago. Many, many thanks to everyone involved in fixing it! :-)
Comment 48 Brendan Lawlor 2024-08-27 13:45:39 UTC
(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.
Comment 49 Jonathan Druart 2024-10-01 12:04:59 UTC
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.
Comment 50 Brendan Lawlor 2024-10-01 13:36:40 UTC
(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]]
Comment 51 Jonathan Druart 2024-10-01 13:40:38 UTC
We should discuss all this on bug 27467. You will find the exact same link there ;)

spoiler: deepLink is not what we want.