Bugzilla – Attachment 163222 Details for
Bug 36120
Add pickup locations to bookings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36120: Add pickup locations to place bookings modal
Bug-36120-Add-pickup-locations-to-place-bookings-m.patch (text/plain), 7.56 KB, created by
Martin Renvoize (ashimema)
on 2024-03-15 12:01:53 UTC
(
hide
)
Description:
Bug 36120: Add pickup locations to place bookings modal
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-03-15 12:01:53 UTC
Size:
7.56 KB
patch
obsolete
>From e6ea6f3557071321a74260d3a4cb4e1785f169ba Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 7 Mar 2024 13:18:19 +0000 >Subject: [PATCH] Bug 36120: Add pickup locations to place bookings modal > >This patch adds a call to /biblios/biblionumber/pickup_locations to >fetch valid pickup locations for the biblio. > >Upon selecting a pickup location we adapt the item select to only allow >for selecting items returned as valid for pickup at the selected >location. > >Signed-off-by: Lisette Scheer <lisette.scheer@bywatersolutions.com> >--- > .../prog/en/includes/modals/place_booking.inc | 6 ++ > .../prog/js/place_booking_modal.js | 81 ++++++++++++++++++- > 2 files changed, 85 insertions(+), 2 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/modals/place_booking.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/place_booking.inc >index adaea50c768..1840e2b791f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/modals/place_booking.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/place_booking.inc >@@ -25,6 +25,12 @@ > </select> > <div class="hint">Enter patron card number or partial name</div> > </li> >+ <li> >+ <label class="required" for="booking_pickup">Pickup at:</label> >+ <select name="booking_pickup" id="pickup_library_id" required="required" disabled="true"></select> >+ <span class="required">Required</span> >+ </li> >+ <li> > <label for="booking_item_id">Item: </label> > <select name="booking_item_id" id="booking_item_id" disabled="true"> > <option value="0">Any item</option> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/place_booking_modal.js b/koha-tmpl/intranet-tmpl/prog/js/place_booking_modal.js >index 832ee2a6a1d..99ce1cfac87 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/place_booking_modal.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/place_booking_modal.js >@@ -108,6 +108,60 @@ $('#placeBookingModal').on('show.bs.modal', function(e) { > > $('#booking_patron_id').on('select2:select', function (e) { > booking_patron = e.params.data; >+ $("#pickup_library_id").prop("disabled", false); >+ }); >+ >+ // Pickup location select2 >+ let pickup_url = '/api/v1/biblios/' + biblionumber + '/pickup_locations'; >+ $("#pickup_library_id").kohaSelect({ >+ dropdownParent: $(".modal-content", "#placeBookingModal"), >+ width: '50%', >+ dropdownAutoWidth: true, >+ allowClear: false, >+ ajax: { >+ url: pickup_url, >+ delay: 300, // wait 300 milliseconds before triggering the request >+ cache: true, >+ dataType: 'json', >+ data: function (params) { >+ var search_term = (params.term === undefined) ? '' : params.term; >+ var query = { >+ "q": JSON.stringify({"name":{"-like":'%'+search_term+'%'}}), >+ "_order_by": "name", >+ "_page": params.page >+ }; >+ query["patron_id"] = booking_patron.patron_id; >+ return query; >+ }, >+ processResults: function (data) { >+ var results = []; >+ data.results.forEach( function ( pickup_location ) { >+ results.push( >+ { >+ "id": pickup_location.library_id.escapeHtml(), >+ "text": pickup_location.name.escapeHtml(), >+ "needs_override": pickup_location.needs_override, >+ "pickup_items": pickup_location.pickup_items, >+ } >+ ); >+ }); >+ return { "results": results, "pagination": { "more": data.pagination.more } }; >+ } >+ }, >+ templateResult: function (state) { >+ var $text; >+ if ( state.needs_override === true ) { >+ $text = $( >+ '<span>' + state.text + '</span> <span style="float:right;" title="' + >+ __("This pickup location is not allowed according to circulation rules") + >+ '"><i class="fa fa-exclamation-circle" aria-hidden="true"></i></span>' >+ ); >+ } >+ else { >+ $text = $('<span>'+state.text+'</span>'); >+ } >+ return $text; >+ }, > }); > > // Adopt periodPicker >@@ -310,6 +364,23 @@ $('#placeBookingModal').on('show.bs.modal', function(e) { > periodPicker.redraw(); > }); > >+ // Setup listener for pickup location select2 >+ $('#pickup_library_id').on('select2:select', function(e) { >+ let valid_items = e.params.data.pickup_items; >+ >+ // Disable items not available at the pickup location >+ $("#booking_item_id > option").each(function() { >+ let option = $(this); >+ let item_id = option.val(); >+ if (valid_items.includes(parseInt(item_id))) { >+ option.prop('disabled',false); >+ } else { >+ option.prop('disabled',true); >+ } >+ }); >+ $('#booking_item_id').trigger('change.select2'); >+ }); >+ > // Set onChange for flatpickr > let changeExists = periodPicker.config.onChange.filter(f => f.name ==='periodChange'); > if(changeExists.length === 0) { >@@ -446,6 +517,8 @@ $("#placeBookingForm").on('submit', function(e) { > > let start_date = $('#booking_start_date').val(); > let end_date = $('#booking_end_date').val(); >+ let pickup_library_id = $('#pickup_library_id').val(); >+ let biblio_id = $('#booking_biblio_id').val(); > let item_id = $('#booking_item_id').val(); > > if (!booking_id) { >@@ -454,7 +527,8 @@ $("#placeBookingForm").on('submit', function(e) { > JSON.stringify({ > "start_date": start_date, > "end_date": end_date, >- "biblio_id": $('#booking_biblio_id').val(), >+ "pickup_library_id": pickup_library_id, >+ "biblio_id": biblio_id, > "item_id": item_id != 0 ? item_id : null, > "patron_id": $('#booking_patron_id').find(':selected').val() > }) >@@ -505,7 +579,8 @@ $("#placeBookingForm").on('submit', function(e) { > "booking_id": booking_id, > "start_date": start_date, > "end_date": end_date, >- "biblio_id": $('#booking_biblio_id').val(), >+ "pickup_library_id": pickup_library_id, >+ "biblio_id": biblio_id, > "item_id": item_id != 0 ? item_id : null, > "patron_id": $('#booking_patron_id').find(':selected').val() > }) >@@ -554,6 +629,8 @@ $('#placeBookingModal').on('hidden.bs.modal', function (e) { > $('#booking_patron_id').val(null).trigger('change'); > $('#booking_patron_id').empty(); > $('#booking_item_id').val(0).trigger('change'); >+ $('#pickup_library_id').val(null).trigger('change'); >+ $('#pickup_library_id').empty(); > $('#period').get(0)._flatpickr.clear(); > $('#booking_start_date').val(''); > $('#booking_end_date').val(''); >-- >2.44.0
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 36120
:
162911
|
162912
|
162914
|
162915
|
162916
|
162917
|
162918
|
162919
|
162920
|
162921
|
162922
|
162923
|
162924
|
162925
|
162926
|
162927
|
162928
|
162976
|
163218
|
163219
|
163220
|
163221
|
163222
|
163223
|
163224
|
163435
|
163436
|
163437
|
163438
|
163439
|
163440
|
163441
|
163442
|
163443
|
163444
|
163445
|
163446
|
163447
|
163448
|
163565
|
163566
|
163567
|
163568
|
163569
|
163570
|
163571
|
163603
|
163604
|
163605
|
163606
|
163607
|
163608
|
163609
|
163610
|
163611
|
163612
|
163613
|
163635
|
163636
|
165140
|
165175
|
165176
|
165177
|
165178
|
165179
|
165180
|
165181
|
165182
|
165183
|
165184
|
165185
|
165186
|
165187
|
165188
|
165214
|
165215
|
165216
|
165419
|
165420
|
165421
|
165422
|
165423
|
165424
|
165425
|
165426
|
165427
|
165428
|
165429
|
165430
|
165431
|
165432
|
165433
|
165434
|
165435
|
165984
|
165985
|
165986
|
165987
|
165988
|
165989
|
165990
|
165991
|
165992
|
165993
|
165994
|
165995
|
165996
|
165997
|
165998
|
165999
|
166000
|
166001
|
166002