View | Details | Raw Unified | Return to bug 38222
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/modals/cancel_booking.inc (+19 lines)
Lines 1-3 Link Here
1
[% USE AuthorisedValues %]
1
<!-- Cancel booking modal -->
2
<!-- Cancel booking modal -->
2
<div class="modal" id="cancelBookingModal" tabindex="-1" role="dialog" aria-labelledby="cancelBookingLabel">
3
<div class="modal" id="cancelBookingModal" tabindex="-1" role="dialog" aria-labelledby="cancelBookingLabel">
3
    <form method="get" id="cancelBookingForm">
4
    <form method="get" id="cancelBookingForm">
Lines 11-16 Link Here
11
                    <div id="cancel_booking_result"></div>
12
                    <div id="cancel_booking_result"></div>
12
                    <input type="hidden" name="booking_id" id="cancel_booking_id">
13
                    <input type="hidden" name="booking_id" id="cancel_booking_id">
13
                    <p>Are you sure you want to cancel this booking?</p>
14
                    <p>Are you sure you want to cancel this booking?</p>
15
                    <fieldset class="brief">
16
                        [% SET booking_cancellation = AuthorisedValues.GetAuthValueDropbox('BOOKING_CANCELLATION') %]
17
                        <div class="combobox-container">
18
                            <label for="cancellation-reason" class="form-label">Cancellation Reason:</label>
19
                            <input type="text" id="cancellation-reason" name="cancellation_reason" class="form-control" />
20
                            <ul id="cancellation-reason-list" class="dropdown-menu position-fixed" style="max-height: 200px; overflow-y: auto; max-width: fit-content;">
21
                                [% IF booking_cancellation.count %]
22
                                    [% FOR reason IN booking_cancellation %]
23
                                        <li>
24
                                            <button type="button" class="dropdown-item" data-id="[% reason.authorised_value | html %]">
25
                                                [% reason.lib | html %]
26
                                            </button>
27
                                        </li>
28
                                    [% END %]
29
                                [% END %]
30
                            </ul>
31
                        </div>
32
                    </fieldset> <!-- /.brief -->
14
                </div> <!-- /.modal-body -->
33
                </div> <!-- /.modal-body -->
15
                <div class="modal-footer">
34
                <div class="modal-footer">
16
                    <button type="submit" class="btn btn-default approve"><i class="fa fa-check"></i> Yes, cancel booking</button>
35
                    <button type="submit" class="btn btn-default approve"><i class="fa fa-check"></i> Yes, cancel booking</button>
(-)a/koha-tmpl/intranet-tmpl/prog/js/cancel_booking_modal.js (-6 / +13 lines)
Lines 9-20 Link Here
9
    async function handleSubmit(e) {
9
    async function handleSubmit(e) {
10
        e.preventDefault();
10
        e.preventDefault();
11
11
12
        const bookingIdInput = document.getElementById("cancel_booking_id");
12
        const target = e.target;
13
        if (!bookingIdInput) {
13
        if (!(target instanceof HTMLFormElement)) {
14
            return;
14
            return;
15
        }
15
        }
16
16
17
        const bookingId = bookingIdInput.value;
17
        const formData = new FormData(target);
18
        const bookingId = formData.get("booking_id");
18
        if (!bookingId) {
19
        if (!bookingId) {
19
            return;
20
            return;
20
        }
21
        }
Lines 22-28 Link Here
22
        let [error, response] = await catchError(
23
        let [error, response] = await catchError(
23
            fetch(`/api/v1/bookings/${bookingId}`, {
24
            fetch(`/api/v1/bookings/${bookingId}`, {
24
                method: "PATCH",
25
                method: "PATCH",
25
                body: JSON.stringify({ status: "cancelled" }),
26
                body: JSON.stringify({
27
                    status: "cancelled",
28
                    cancellation_reason: formData.get("cancellation_reason"),
29
                }),
26
                headers: {
30
                headers: {
27
                    "Content-Type": "application/json",
31
                    "Content-Type": "application/json",
28
                },
32
                },
Lines 43-49 Link Here
43
47
44
        cancel_success = true;
48
        cancel_success = true;
45
        bookings_table?.api().ajax.reload();
49
        bookings_table?.api().ajax.reload();
46
        timeline?.itemsData.remove(Number(booking_id));
50
        try {
51
            timeline?.itemsData.remove(Number(bookingId));
52
        } catch {
53
            console.info("Timeline component not found. Skipping...");
54
        }
47
55
48
        $("#cancelBookingModal").modal("hide");
56
        $("#cancelBookingModal").modal("hide");
49
57
50
- 

Return to bug 38222