diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 45c2edc7aa..6746f8023d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -2018,65 +2018,64 @@ bundle_form_active = item_id; }); - function addToBundle(url, data) { + function addToBundle(item_id, data) { /* Send the data using post with external_id */ - var posting = $.post({ - url: url, - data: JSON.stringify(data), - contentType: "application/json; charset=utf-8", - dataType: "json", - }); + const client = APIClient.item; + const posting = client.bundled_items.add(item_id, data, { return_response: true }); const barcode = data.external_id; const marc_link = data.marc_link; /* Report the results */ - posting.done(function (data) { - $("#addResult").replaceWith('
' + _("Success: Added '%s'").format(barcode) + "
"); - $("#external_id").val("").focus(); - bundle_changed = 1; - }); - posting.fail(function (data) { - if (data.status === 409) { - var response = data.responseJSON; - if (response.error_code === "already_bundled") { - $("#addResult").replaceWith('
' + _("Warning: Item '%s' already attached").format(barcode) + "
"); - } else if (response.error_code === "bundle_checkout_out") { - $("#addResult").replaceWith('
' + _("Failure: Bundle is currently checked out") + "
"); - } else if (response.error_code === "checked_out") { - const button = $('