Bug 27016

Summary: Make the pickup locations dropdowns use Select2
Product: Koha Reporter: Tomás Cohen Arazi (tcohen) <tomascohen>
Component: Hold requestsAssignee: Tomás Cohen Arazi (tcohen) <tomascohen>
Status: CLOSED FIXED QA Contact: Nick Clemens (kidclamp) <nick>
Severity: enhancement    
Priority: P5 - low CC: andrew, caroline.cyr-la-rose, david, fridolin.somers, gmcharlt, jonathan.druart, martin.renvoize, nick
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27863
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
This enhancement improves the display of the pickup library dropdown list in the holds section for a record, particularly for long lists. Enhancements include being able to start typing the name of the library and search for the library.
Version(s) released in:
21.05.00
Circulation function:
Bug Depends on: 26988, 27015    
Bug Blocks: 27732    
Attachments: Bug 27016: Make the pickup locations dropdowns use Select2
Bug 27016: Make the pickup locations dropdowns use Select2
Bug 27016: Make the pickup locations dropdowns use Select2
Bug 27016: Make the pickup locations dropdowns use Select2
Bug 27016: (QA follow-up) Move allowClear out of ajax
Bug 27016: Use $.fn.select2.defaults.set to set select2's width

Description Tomás Cohen Arazi (tcohen) 2020-11-13 13:33:30 UTC
On top of bug 26988, we can nicely use Select2 on those dropdowns. This would be beneficial on sites with many branches.
Comment 1 Tomás Cohen Arazi (tcohen) 2020-11-17 15:19:42 UTC Comment hidden (obsolete)
Comment 2 Tomás Cohen Arazi (tcohen) 2020-11-17 16:00:23 UTC
Created attachment 113740 [details] [review]
Bug 27016: Make the pickup locations dropdowns use Select2

On the shoulders of bug 27015, this patch makes the pickup locations
dropdowns use Select2 to handle both fetching the pickup location
on-deman through the API, and also searching for them.

This provides a better user experience for really big lists.

To test:
1. Have some holds on a biblio
=> SUCCESS: Bug 26988 works, made it load the data when you click on the
dropdowns.
2. Apply this patch
3. Reload the page
=> SUCCESS: Similar-ish behaviour
=> SUCCESS: Notice you can search for branch names and make the list
shrink
4. Sign off :-D
Comment 3 David Nind 2020-11-17 20:05:14 UTC
Created attachment 113760 [details] [review]
Bug 27016: Make the pickup locations dropdowns use Select2

On the shoulders of bug 27015, this patch makes the pickup locations
dropdowns use Select2 to handle both fetching the pickup location
on-deman through the API, and also searching for them.

This provides a better user experience for really big lists.

To test:
1. Have some holds on a biblio
=> SUCCESS: Bug 26988 works, made it load the data when you click on the
dropdowns.
2. Apply this patch
3. Reload the page
=> SUCCESS: Similar-ish behaviour
=> SUCCESS: Notice you can search for branch names and make the list
shrink
4. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Comment 4 David Nind 2020-11-17 20:15:59 UTC
The only thing I noticed when testing is that for library names with spaces in the name wrap (such as Institut Protestant de Théologie), rather than being on the same 'line'. 

I'm assuming this is the default behaviour for Select2.
Comment 5 Tomás Cohen Arazi (tcohen) 2020-11-17 21:02:34 UTC
(In reply to David Nind from comment #4)
> The only thing I noticed when testing is that for library names with spaces
> in the name wrap (such as Institut Protestant de Théologie), rather than
> being on the same 'line'. 
> 
> I'm assuming this is the default behaviour for Select2.

Good point. We could fix that. I felt like the experience was better with no geometry changes when the API call gets the results. So I'm open to discuss this.
Comment 6 David Nind 2020-11-18 10:10:21 UTC
I think it is a great improvement.
Comment 7 Tomás Cohen Arazi (tcohen) 2020-11-18 14:07:37 UTC
(In reply to David Nind from comment #6)
> I think it is a great improvement.

Thanks!
Comment 8 Nick Clemens (kidclamp) 2020-11-18 15:49:14 UTC
Created attachment 113791 [details] [review]
Bug 27016: Make the pickup locations dropdowns use Select2

On the shoulders of bug 27015, this patch makes the pickup locations
dropdowns use Select2 to handle both fetching the pickup location
on-deman through the API, and also searching for them.

This provides a better user experience for really big lists.

To test:
1. Have some holds on a biblio
=> SUCCESS: Bug 26988 works, made it load the data when you click on the
dropdowns.
2. Apply this patch
3. Reload the page
=> SUCCESS: Similar-ish behaviour
=> SUCCESS: Notice you can search for branch names and make the list
shrink
4. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 9 Nick Clemens (kidclamp) 2020-11-18 15:49:18 UTC
Created attachment 113792 [details] [review]
Bug 27016: (QA follow-up) Move allowClear out of ajax

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 10 Jonathan Druart 2021-01-04 15:27:45 UTC
Created attachment 114807 [details] [review]
Bug 27016: Use $.fn.select2.defaults.set to set select2's width

See commit ff7318c62ec7097c5b88f7278b71d0cc7feb1f39
    Bug 27124: JS error "select2Width is not defined"
Comment 11 Jonathan Druart 2021-01-04 15:34:32 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 12 Fridolin Somers 2021-01-07 14:50:03 UTC
Enhancement not pushed to 20.11.x