Bugzilla – Attachment 173232 Details for
Bug 38222
Let staff pick a cancellation reason when canceling a booking
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38222: Add handling for cancellation reasons to cancel booking modal template, associated script
Bug-38222-Add-handling-for-cancellation-reasons-to.patch (text/plain), 4.62 KB, created by
Paul Derscheid
on 2024-10-23 16:57:59 UTC
(
hide
)
Description:
Bug 38222: Add handling for cancellation reasons to cancel booking modal template, associated script
Filename:
MIME Type:
Creator:
Paul Derscheid
Created:
2024-10-23 16:57:59 UTC
Size:
4.62 KB
patch
obsolete
>From 7699968b889aec6de8095b2d2b8b9037fb08c3d3 Mon Sep 17 00:00:00 2001 >From: Paul Derscheid <paul.derscheid@lmscloud.de> >Date: Wed, 23 Oct 2024 16:43:16 +0000 >Subject: [PATCH] Bug 38222: Add handling for cancellation reasons to cancel > booking modal template, associated script >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Sponsored-by: Büchereizentrale Schleswig-Holstein <https://www.bz-sh.de/> >--- > .../en/includes/modals/cancel_booking.inc | 19 +++++++++++++++++++ > .../prog/js/cancel_booking_modal.js | 18 +++++++++++++----- > 2 files changed, 32 insertions(+), 5 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/modals/cancel_booking.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/cancel_booking.inc >index c9940bc8dc..5cc699d899 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/modals/cancel_booking.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/cancel_booking.inc >@@ -1,3 +1,4 @@ >+[% USE AuthorisedValues %] > <!-- Cancel booking modal --> > <div class="modal" id="cancelBookingModal" tabindex="-1" role="dialog" aria-labelledby="cancelBookingLabel"> > <form method="get" id="cancelBookingForm"> >@@ -11,6 +12,24 @@ > <div id="cancel_booking_result"></div> > <input type="hidden" name="booking_id" id="cancel_booking_id"> > <p>Are you sure you want to cancel this booking?</p> >+ <fieldset class="brief"> >+ [% SET booking_cancellation = AuthorisedValues.GetAuthValueDropbox('BOOKING_CANCELLATION') %] >+ <div class="combobox-container"> >+ <label for="cancellation-reason" class="form-label">Cancellation Reason:</label> >+ <input type="text" id="cancellation-reason" name="cancellation_reason" class="form-control" /> >+ <ul id="cancellation-reason-list" class="dropdown-menu position-fixed" style="max-height: 200px; overflow-y: auto; max-width: fit-content;"> >+ [% IF booking_cancellation.count %] >+ [% FOR reason IN booking_cancellation %] >+ <li> >+ <button type="button" class="dropdown-item" data-id="[% reason.authorised_value | html %]"> >+ [% reason.lib | html %] >+ </button> >+ </li> >+ [% END %] >+ [% END %] >+ </ul> >+ </div> >+ </fieldset> <!-- /.brief --> > </div> <!-- /.modal-body --> > <div class="modal-footer"> > <button type="submit" class="btn btn-default approve"><i class="fa fa-check"></i> Yes, cancel booking</button> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/cancel_booking_modal.js b/koha-tmpl/intranet-tmpl/prog/js/cancel_booking_modal.js >index 9201494066..4cfdbafa1f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/cancel_booking_modal.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/cancel_booking_modal.js >@@ -9,12 +9,13 @@ > async function handleSubmit(e) { > e.preventDefault(); > >- const bookingIdInput = document.getElementById("cancel_booking_id"); >- if (!bookingIdInput) { >+ const target = e.target; >+ if (!(target instanceof HTMLFormElement)) { > return; > } > >- const bookingId = bookingIdInput.value; >+ const formData = new FormData(target); >+ const bookingId = formData.get("booking_id"); > if (!bookingId) { > return; > } >@@ -22,7 +23,10 @@ > let [error, response] = await catchError( > fetch(`/api/v1/bookings/${bookingId}`, { > method: "PATCH", >- body: JSON.stringify({ status: "cancelled" }), >+ body: JSON.stringify({ >+ status: "cancelled", >+ cancellation_reason: formData.get("cancellation_reason"), >+ }), > headers: { > "Content-Type": "application/json", > }, >@@ -43,7 +47,11 @@ > > cancel_success = true; > bookings_table?.api().ajax.reload(); >- timeline?.itemsData.remove(Number(booking_id)); >+ try { >+ timeline?.itemsData.remove(Number(bookingId)); >+ } catch { >+ console.info("Timeline component not found. Skipping..."); >+ } > > $("#cancelBookingModal").modal("hide"); > >-- >2.47.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 38222
:
173230
|
173231
|
173232
|
173233
|
173264
|
173265
|
173277
|
173278
|
173281
|
173282
|
173312
|
173313
|
173314
|
173315
|
173316
|
173317
|
173318
|
173319
|
173320
|
173321
|
173322
|
173323
|
173336
|
173337
|
173338
|
173339