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

(-)a/koha-tmpl/intranet-tmpl/prog/js/holds.js (-1 / +56 lines)
Lines 960-965 $(document).ready(function () { Link Here
960
        return false;
960
        return false;
961
    });
961
    });
962
962
963
    if (holds_table_patron_page()) {
964
        $("#cancelModalConfirmBtn").click(function (e) {
965
            e.preventDefault();
966
            let formInputs = {};
967
            formInputs["reserve_id"] = $(
968
                "#cancel_modal_form :input[name='reserve_id']"
969
            )
970
                .map(function () {
971
                    return $(this).val();
972
                })
973
                .get();
974
            formInputs["cancellation-reason"] = $(
975
                "#cancel_modal_form :input[name='cancellation-reason']"
976
            ).val();
977
            cancel_holds(
978
                formInputs["reserve_id"],
979
                formInputs["cancellation-reason"]
980
            )
981
                .success(function () {
982
                    holdsTable.api().ajax.reload();
983
                })
984
                .fail(function (jqXHR) {
985
                    $("#cancelModal .modal-body").prepend(
986
                        '<div class="alert alert-danger">' +
987
                            jqXHR.responseJSON.error +
988
                            "</div>"
989
                    );
990
                    $("#cancelModalConfirmBtn").prop("disabled", true);
991
                })
992
                .done(function () {
993
                    $("#cancelModal").modal("hide");
994
                    if ($(".select_hold_all").prop("checked")) {
995
                        $(".select_hold_all").click();
996
                    }
997
                });
998
        });
999
    }
1000
1001
    function cancel_holds(hold_ids, cancellation_reason) {
1002
        return $.ajax({
1003
            method: "DELETE",
1004
            url: "/api/v1/holds/cancellation_bulk",
1005
            contentType: "application/json",
1006
            data: JSON.stringify({
1007
                hold_ids: hold_ids,
1008
                cancellation_reason: cancellation_reason,
1009
            }),
1010
        });
1011
    }
1012
1013
    $("#cancelModal").on("hidden.bs.modal", function () {
1014
        $("#cancelModal .modal-body .alert-danger").remove();
1015
        $("#cancelModalConfirmBtn").prop("disabled", false);
1016
        holdsTable.api().ajax.reload();
1017
    });
1018
963
    $("#group-modal-submit").click(function (e) {
1019
    $("#group-modal-submit").click(function (e) {
964
        e.preventDefault();
1020
        e.preventDefault();
965
        let selected_holds = get_selected_holds_data();
1021
        let selected_holds = get_selected_holds_data();
966
- 

Return to bug 40551