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 1177-1182 $(document).ready(function () { Link Here
1177
        return false;
1177
        return false;
1178
    });
1178
    });
1179
1179
1180
    if (holds_table_patron_page()) {
1181
        $("#cancelModalConfirmBtn").click(function (e) {
1182
            e.preventDefault();
1183
            let formInputs = {};
1184
            formInputs["reserve_id"] = $(
1185
                "#cancel_modal_form :input[name='reserve_id']"
1186
            )
1187
                .map(function () {
1188
                    return $(this).val();
1189
                })
1190
                .get();
1191
            formInputs["cancellation-reason"] = $(
1192
                "#cancel_modal_form :input[name='cancellation-reason']"
1193
            ).val();
1194
            cancel_holds(
1195
                formInputs["reserve_id"],
1196
                formInputs["cancellation-reason"]
1197
            )
1198
                .success(function () {
1199
                    holdsTable.api().ajax.reload();
1200
                })
1201
                .fail(function (jqXHR) {
1202
                    $("#cancelModal .modal-body").prepend(
1203
                        '<div class="alert alert-danger">' +
1204
                            jqXHR.responseJSON.error +
1205
                            "</div>"
1206
                    );
1207
                    $("#cancelModalConfirmBtn").prop("disabled", true);
1208
                })
1209
                .done(function () {
1210
                    $("#cancelModal").modal("hide");
1211
                    if ($(".select_hold_all").prop("checked")) {
1212
                        $(".select_hold_all").click();
1213
                    }
1214
                });
1215
        });
1216
    }
1217
1218
    function cancel_holds(hold_ids, cancellation_reason) {
1219
        return $.ajax({
1220
            method: "DELETE",
1221
            url: "/api/v1/holds/cancellation_bulk",
1222
            contentType: "application/json",
1223
            data: JSON.stringify({
1224
                hold_ids: hold_ids,
1225
                cancellation_reason: cancellation_reason,
1226
            }),
1227
        });
1228
    }
1229
1230
    $("#cancelModal").on("hidden.bs.modal", function () {
1231
        $("#cancelModal .modal-body .alert-danger").remove();
1232
        $("#cancelModalConfirmBtn").prop("disabled", false);
1233
        holdsTable.api().ajax.reload();
1234
    });
1235
1180
    $("#group-modal-submit").click(function (e) {
1236
    $("#group-modal-submit").click(function (e) {
1181
        e.preventDefault();
1237
        e.preventDefault();
1182
        let selected_holds = get_selected_holds_data();
1238
        let selected_holds = get_selected_holds_data();
1183
- 

Return to bug 40551