Koha/koha-tmpl/intranet-tmpl/prog/js/ill-batch.js
Pedro Amorim edb048de78
Bug 30719: (QA follow-up) Rename illbatches endpoint to ill/batches
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-10-17 14:45:20 -03:00

49 lines
1.4 KiB
JavaScript

(function () {
// Enable the modal to be opened from anywhere
// If we're working with an existing batch, set the ID so the
// modal can access it
window.openBatchModal = function (id, backend) {
var idEl = document.getElementById('ill-batch-details');
idEl.dataset.backend = backend;
if (id) {
idEl.dataset.batchId = id;
}
$('#ill-batch-modal').modal({ show: true });
};
// Make a batch API call, returning the resulting promise
window.doBatchApiRequest = function (url, options) {
var batchListApi = '/api/v1/ill/batches';
var fullUrl = batchListApi + (url ? url : '');
return doApiRequest(fullUrl, options);
};
// Make a "create local ILL submission" call
window.doCreateSubmission = function (body, options) {
options = Object.assign(
options || {},
{
headers: {
'Content-Type': 'application/json'
},
method: 'POST',
body: JSON.stringify(body)
}
);
return doApiRequest(
'/api/v1/ill/requests',
options
)
}
// Make an API call, returning the resulting promise
window.doApiRequest = function (url, options) {
return fetch(url, options);
};
// Display an API error
window.handleApiError = function (error) {
alert(error);
};
})();