Lines 1759-1794
Note that permanent location is a code, and location may be an authval.
Link Here
|
1759 |
bundle_form_active = item_id; |
1759 |
bundle_form_active = item_id; |
1760 |
}); |
1760 |
}); |
1761 |
|
1761 |
|
1762 |
$("#addToBundleForm").submit(function(event) { |
1762 |
function addToBundle (url, data) { |
1763 |
|
|
|
1764 |
/* stop form from submitting normally */ |
1765 |
event.preventDefault(); |
1766 |
|
1767 |
/* get the action attribute from the <form action=""> element */ |
1768 |
var $form = $(this), |
1769 |
url = $form.attr('action'); |
1770 |
|
1771 |
/* Send the data using post with external_id */ |
1763 |
/* Send the data using post with external_id */ |
1772 |
var posting = $.post({ |
1764 |
var posting = $.post({ |
1773 |
url: url, |
1765 |
url: url, |
1774 |
data: JSON.stringify({ external_id: $('#external_id').val()}), |
1766 |
data: JSON.stringify(data), |
1775 |
contentType: "application/json; charset=utf-8", |
1767 |
contentType: "application/json; charset=utf-8", |
1776 |
dataType: "json" |
1768 |
dataType: "json" |
1777 |
}); |
1769 |
}); |
1778 |
|
1770 |
|
|
|
1771 |
const barcode = data.external_id; |
1772 |
|
1779 |
/* Report the results */ |
1773 |
/* Report the results */ |
1780 |
posting.done(function(data) { |
1774 |
posting.done(function(data) { |
1781 |
var barcode = $('#external_id').val(); |
|
|
1782 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-success">'+_("Success: Added '%s'").format(barcode)+'</div>'); |
1775 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-success">'+_("Success: Added '%s'").format(barcode)+'</div>'); |
1783 |
$('#external_id').val('').focus(); |
1776 |
$('#external_id').val('').focus(); |
1784 |
bundle_changed = 1; |
1777 |
bundle_changed = 1; |
1785 |
}); |
1778 |
}); |
1786 |
posting.fail(function(data) { |
1779 |
posting.fail(function(data) { |
1787 |
var barcode = $('#external_id').val(); |
|
|
1788 |
if ( data.status === 409 ) { |
1780 |
if ( data.status === 409 ) { |
1789 |
var response = data.responseJSON; |
1781 |
var response = data.responseJSON; |
1790 |
if ( response.key === "PRIMARY" ) { |
1782 |
if ( response.key === "PRIMARY" ) { |
1791 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-warning">'+_("Warning: Item '%s' already attached").format(barcode)+'</div>'); |
1783 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-warning">'+_("Warning: Item '%s' already attached").format(barcode)+'</div>'); |
|
|
1784 |
} else if (response.key === 'checked_out') { |
1785 |
const button = $('<button type="button">') |
1786 |
.addClass('btn btn-xs') |
1787 |
.text(__('Check in and add to bundle')) |
1788 |
.on('click', function () { |
1789 |
addToBundle(url, { external_id: barcode, force_checkin: true }); |
1790 |
}); |
1791 |
$('#addResult') |
1792 |
.empty() |
1793 |
.attr('class', 'alert alert-warning') |
1794 |
.append(__x('Warning: Item {barcode} is checked out', { barcode })) |
1795 |
.append(' ', button); |
1796 |
} else if (response.key === 'failed_checkin') { |
1797 |
$('#addResult') |
1798 |
.empty() |
1799 |
.attr('class', 'alert alert-danger') |
1800 |
.append(__x('Failure: Item {barcode} cannot be checked in', { barcode })) |
1792 |
} else { |
1801 |
} else { |
1793 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' belongs to another bundle").format(barcode)+'</div>'); |
1802 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' belongs to another bundle").format(barcode)+'</div>'); |
1794 |
} |
1803 |
} |
Lines 1799-1804
Note that permanent location is a code, and location may be an authval.
Link Here
|
1799 |
} |
1808 |
} |
1800 |
$('#external_id').val('').focus(); |
1809 |
$('#external_id').val('').focus(); |
1801 |
}); |
1810 |
}); |
|
|
1811 |
} |
1812 |
|
1813 |
$("#addToBundleForm").submit(function(event) { |
1814 |
/* stop form from submitting normally */ |
1815 |
event.preventDefault(); |
1816 |
|
1817 |
const url = this.action; |
1818 |
const data = { external_id: this.elements.external_id.value }; |
1819 |
|
1820 |
addToBundle(url, data); |
1802 |
}); |
1821 |
}); |
1803 |
|
1822 |
|
1804 |
$("#addToBundleModal").on("hidden.bs.modal", function(e){ |
1823 |
$("#addToBundleModal").on("hidden.bs.modal", function(e){ |