Bugzilla – Attachment 183210 Details for
Bug 39916
The 'Place booking' modal should have cypress tests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39916: Fix race condition in booking modal edit mode
Bug-39916-Fix-race-condition-in-booking-modal-edit.patch (text/plain), 2.36 KB, created by
Martin Renvoize (ashimema)
on 2025-06-12 14:51:51 UTC
(
hide
)
Description:
Bug 39916: Fix race condition in booking modal edit mode
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-06-12 14:51:51 UTC
Size:
2.36 KB
patch
obsolete
>From ff6df5be555c3ec4ff1dfdd976aa0d2a66e3d0d9 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Wed, 11 Jun 2025 11:14:47 +0100 >Subject: [PATCH] Bug 39916: Fix race condition in booking modal edit mode > >When editing an existing booking, the item type field was not being >populated because setFormValues() was triggering the wrong Select2 event. > >The fix ensures both 'change' and 'select2:select' events are triggered >with proper data structure, allowing the item type to be automatically >populated based on the selected item's effective_item_type_id. > >A small timeout prevents race conditions during DOM initialization. >--- > .../prog/js/modals/place_booking.js | 26 +++++++++++++++---- > 1 file changed, 21 insertions(+), 5 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js b/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js >index 8b9f2d91b0c..bed0fe8388c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js >@@ -1113,6 +1113,27 @@ function setFormValues( > }); > } > >+ // If passed an itemnumber, pre-select >+ if (booking_item_id) { >+ // Wait a bit for the item options to be fully created with data attributes >+ setTimeout(function() { >+ $("#booking_item_id").val(booking_item_id).trigger("change"); >+ // Also trigger the select2:select event with proper data >+ let selectedOption = $("#booking_item_id option:selected")[0]; >+ if (selectedOption) { >+ $("#booking_item_id").trigger({ >+ type: "select2:select", >+ params: { >+ data: { >+ id: booking_item_id, >+ element: selectedOption >+ } >+ } >+ }); >+ } >+ }, 100); >+ } >+ > // Set booking start & end if this is an edit > if (start_date) { > // Allow invalid pre-load so setDate can set date range >@@ -1128,11 +1149,6 @@ function setFormValues( > else { > periodPicker.redraw(); > } >- >- // If passed an itemnumber, pre-select >- if (booking_item_id) { >- $("#booking_item_id").val(booking_item_id).trigger("change"); >- } > } > > $("#placeBookingForm").on("submit", function (e) { >-- >2.49.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 39916
:
182515
|
182516
|
182545
|
182546
|
182635
|
182636
|
182637
|
182771
|
182772
|
182773
|
183206
|
183207
|
183208
|
183209
| 183210