Bugzilla – Attachment 113738 Details for
Bug 27016
Make the pickup locations dropdowns use Select2
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27016: Make the pickup locations dropdowns use Select2
Bug-27016-Make-the-pickup-locations-dropdowns-use-.patch (text/plain), 4.93 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-11-17 15:19:42 UTC
(
hide
)
Description:
Bug 27016: Make the pickup locations dropdowns use Select2
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-11-17 15:19:42 UTC
Size:
4.93 KB
patch
obsolete
>From 4eaa841037e407719f45424c41bbe3576bc2ba21 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 17 Nov 2020 12:08:39 -0300 >Subject: [PATCH] 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 >--- > .../prog/en/modules/reserve/request.tt | 36 ++++++++++++++++++- > koha-tmpl/intranet-tmpl/prog/js/holds.js | 31 ---------------- > 2 files changed, 35 insertions(+), 32 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >index f479387c7ef..4a0fb57eb46 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >@@ -19,6 +19,9 @@ > </head> > > <body id="circ_request" class="catalog"> >+<script> >+ var select2Width = "100%"; >+</script> > [% INCLUDE 'header.inc' %] > [% INCLUDE 'circ-search.inc' %] > >@@ -985,7 +988,7 @@ > [% INCLUDE 'columns_settings.inc' %] > [% Asset.js("lib/hc-sticky.js") | $raw %] > [% Asset.js("js/circ-patron-search-results.js") | $raw %] >- [% Asset.js("js/holds.js") | $raw %] >+ [% INCLUDE 'select2.inc' %] > <script> > var Sticky; > var biblionumber = "[% biblionumber | $raw %]"; >@@ -1150,6 +1153,37 @@ > }); > [% END %] > >+ $(".pickup_location_dropdown").each( function () { >+ var this_dropdown = $(this); >+ var hold_id = $(this).data('hold_id'); >+ >+ this_dropdown.select2({ >+ ajax: { >+ url: '/api/v1/holds/' + encodeURIComponent(hold_id) + '/pickup_locations', >+ allowClear: false, >+ dataType: 'json', >+ data: function (params) { >+ var search_term = (params.term === undefined) ? '' : params.term; >+ var query = { >+ "q": JSON.stringify({"name":{"-like":search_term+'%'}}) >+ }; >+ return query; >+ }, >+ processResults: function (data) { >+ var results = []; >+ data.forEach( function ( library ) { >+ results.push( >+ { >+ "id": library.library_id.escapeHtml(), >+ "text": library.name.escapeHtml() >+ } >+ ); >+ }); >+ return { "results": results }; >+ } >+ } >+ }); >+ }); > }); > > function check() { >diff --git a/koha-tmpl/intranet-tmpl/prog/js/holds.js b/koha-tmpl/intranet-tmpl/prog/js/holds.js >index 66dd265a14e..134194bbfd9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/holds.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/holds.js >@@ -301,35 +301,4 @@ $(document).ready(function() { > } > }); > }); >- >- $(".pickup_location_dropdown").on( "focus",function(){ >- var this_dropdown = $(this); >- if(this_dropdown.data('loaded')===1){ return true}; >- var hold_id = $(this).data('hold_id'); >- $(".loading_"+hold_id).show(); >- var preselected = $(this).data('selected'); >- var api_url = '/api/v1/holds/' + encodeURIComponent(hold_id) + '/pickup_locations'; >- $.ajax({ >- method: "GET", >- url: api_url, >- success: function( data ){ >- var dropdown = ""; >- $.each(data, function(index,library) { >- if( preselected == library.library_id ){ >- selected = ' selected="selected" '; >- } else { selected = ""; } >- dropdown += '<option value="' + library.library_id.escapeHtml() + '"' + selected + '>' + library.name.escapeHtml() + '</option>'; >- }); >- this_dropdown.html(dropdown); >- this_dropdown.data("loaded",1); >- $(".loading_"+hold_id).hide(); >- }, >- error: function( jqXHR, textStatus, errorThrown) { >- alert('There was an error:'+textStatus+" "+errorThrown); >- $(".loading_"+hold_id).hide(); >- }, >- }); >- }); >- >- > }); >-- >2.29.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27016
:
113738
|
113740
|
113760
|
113791
|
113792
|
114807