Lines 1231-1246
Note that permanent location is a code, and location may be an authval.
Link Here
|
1231 |
</div> |
1231 |
</div> |
1232 |
|
1232 |
|
1233 |
[% IF bundlesEnabled %] |
1233 |
[% IF bundlesEnabled %] |
1234 |
<div class="modal" id="bundleItemsModal" tabindex="-1" role="dialog" aria-labelledby="bundleItemsLabel"> |
1234 |
<div class="modal" id="addToBundleModal" tabindex="-1" role="dialog" aria-labelledby="addToBundleLabel"> |
1235 |
<form id="bundleItemsForm" action=""> |
1235 |
<form id="addToBundleForm" action=""> |
1236 |
<div class="modal-dialog" role="document"> |
1236 |
<div class="modal-dialog" role="document"> |
1237 |
<div class="modal-content"> |
1237 |
<div class="modal-content"> |
1238 |
<div class="modal-header"> |
1238 |
<div class="modal-header"> |
1239 |
<button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button> |
1239 |
<button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button> |
1240 |
<h3 id="bundleItemsLabel">Add to bundle</h3> |
1240 |
<h3 id="addToBundleLabel">Add to bundle</h3> |
1241 |
</div> |
1241 |
</div> |
1242 |
<div class="modal-body"> |
1242 |
<div class="modal-body"> |
1243 |
<div id="result"></div> |
1243 |
<div id="addResult"></div> |
1244 |
<fieldset class="rows"> |
1244 |
<fieldset class="rows"> |
1245 |
<ol> |
1245 |
<ol> |
1246 |
<li> |
1246 |
<li> |
Lines 1259-1264
Note that permanent location is a code, and location may be an authval.
Link Here
|
1259 |
</div> |
1259 |
</div> |
1260 |
</form> |
1260 |
</form> |
1261 |
</div> |
1261 |
</div> |
|
|
1262 |
|
1263 |
<div class="modal" id="removeFromBundleModal" tabindex="-1" role="dialog" aria-labelledby="removeFromBundleLabel"> |
1264 |
<form id="removeFromBundleForm" action=""> |
1265 |
<div class="modal-dialog" role="document"> |
1266 |
<div class="modal-content"> |
1267 |
<div class="modal-header"> |
1268 |
<button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button> |
1269 |
<h3 id="removeFromBundleLabel">Remove from bundle</h3> |
1270 |
</div> |
1271 |
<div class="modal-body"> |
1272 |
<div id="removeResult"></div> |
1273 |
<fieldset class="rows"> |
1274 |
<ol> |
1275 |
<li> |
1276 |
<label class="required" for="external_id">Item barcode: </label> |
1277 |
<input type="text" id="rm_external_id" name="external_id" required="required"> |
1278 |
<span class="required">Required</span> |
1279 |
</li> |
1280 |
</ol> |
1281 |
</fieldset> |
1282 |
</div> |
1283 |
<div class="modal-footer"> |
1284 |
<button type="submit" class="btn btn-default">Submit</button> |
1285 |
<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button> |
1286 |
</div> |
1287 |
</div> |
1288 |
</div> |
1289 |
</form> |
1290 |
</div> |
1262 |
[% END %] |
1291 |
[% END %] |
1263 |
|
1292 |
|
1264 |
[% MACRO jsinclude BLOCK %] |
1293 |
[% MACRO jsinclude BLOCK %] |
Lines 1586-1592
Note that permanent location is a code, and location may be an authval.
Link Here
|
1586 |
function createChild ( row, itemnumber ) { |
1615 |
function createChild ( row, itemnumber ) { |
1587 |
|
1616 |
|
1588 |
// Toolbar |
1617 |
// Toolbar |
1589 |
var bundle_toolbar = $('<div id="toolbar" class="btn-toolbar"><a class="btn btn-default" data-toggle="modal" data-target="#bundleItemsModal" data-item="' + itemnumber + '"><i class="fa fa-plus"></i> Add to bundle</a></div>'); |
1618 |
var bundle_toolbar = $('<div id="toolbar" class="btn-toolbar"></div>'); |
|
|
1619 |
bundle_toolbar.append('<a class="btn btn-default" data-toggle="modal" data-target="#addToBundleModal" data-item="' + itemnumber + '"><i class="fa fa-plus"></i> Add to bundle</a>'); |
1620 |
bundle_toolbar.append('<a class="btn btn-default" data-toggle="modal" data-target="#removeFromBundleModal" data-item="' + itemnumber + '"><i class="fa fa-minus"></i> Remove from bundle</a>'); |
1590 |
|
1621 |
|
1591 |
// This is the table we'll convert into a DataTable |
1622 |
// This is the table we'll convert into a DataTable |
1592 |
var bundles_table = $('<table class="display tbundle" data-itemnumber="'+itemnumber+'" id="bundle_table_'+itemnumber+'" width="100%"/>'); |
1623 |
var bundles_table = $('<table class="display tbundle" data-itemnumber="'+itemnumber+'" id="bundle_table_'+itemnumber+'" width="100%"/>'); |
Lines 1715-1731
Note that permanent location is a code, and location may be an authval.
Link Here
|
1715 |
|
1746 |
|
1716 |
var bundle_changed; |
1747 |
var bundle_changed; |
1717 |
var bundle_form_active; |
1748 |
var bundle_form_active; |
1718 |
$("#bundleItemsModal").on("shown.bs.modal", function(e){ |
1749 |
$("#addToBundleModal").on("shown.bs.modal", function(e){ |
1719 |
var button = $(e.relatedTarget); |
1750 |
var button = $(e.relatedTarget); |
1720 |
var item_id = button.data('item'); |
1751 |
var item_id = button.data('item'); |
1721 |
$("#result").replaceWith('<div id="result"></div>'); |
1752 |
$("#addResult").replaceWith('<div id="addResult"></div>'); |
1722 |
$("#bundleItemsForm").attr('action', '/api/v1/items/' + item_id + '/bundled_items'); |
1753 |
$("#addToBundleForm").attr('action', '/api/v1/items/' + item_id + '/bundled_items'); |
1723 |
$("#external_id").focus(); |
1754 |
$("#external_id").focus(); |
1724 |
bundle_changed = 0; |
1755 |
bundle_changed = 0; |
1725 |
bundle_form_active = item_id; |
1756 |
bundle_form_active = item_id; |
1726 |
}); |
1757 |
}); |
1727 |
|
1758 |
|
1728 |
$("#bundleItemsForm").submit(function(event) { |
1759 |
$("#addToBundleForm").submit(function(event) { |
1729 |
|
1760 |
|
1730 |
/* stop form from submitting normally */ |
1761 |
/* stop form from submitting normally */ |
1731 |
event.preventDefault(); |
1762 |
event.preventDefault(); |
Lines 1745-1751
Note that permanent location is a code, and location may be an authval.
Link Here
|
1745 |
/* Report the results */ |
1776 |
/* Report the results */ |
1746 |
posting.done(function(data) { |
1777 |
posting.done(function(data) { |
1747 |
var barcode = $('#external_id').val(); |
1778 |
var barcode = $('#external_id').val(); |
1748 |
$('#result').replaceWith('<div id="result" class="alert alert-success">Success: Added '+barcode+'</div>'); |
1779 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-success">Success: Added '+barcode+'</div>'); |
1749 |
$('#external_id').val('').focus(); |
1780 |
$('#external_id').val('').focus(); |
1750 |
bundle_changed = 1; |
1781 |
bundle_changed = 1; |
1751 |
}); |
1782 |
}); |
Lines 1754-1771
Note that permanent location is a code, and location may be an authval.
Link Here
|
1754 |
if ( data.status === 409 ) { |
1785 |
if ( data.status === 409 ) { |
1755 |
var response = data.responseJSON; |
1786 |
var response = data.responseJSON; |
1756 |
if ( response.key === "PRIMARY" ) { |
1787 |
if ( response.key === "PRIMARY" ) { |
1757 |
$('#result').replaceWith('<div id="result" class="alert alert-warning">Warning: Item '+barcode+' already attached</div>'); |
1788 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-warning">Warning: Item '+barcode+' already attached</div>'); |
1758 |
} else { |
1789 |
} else { |
1759 |
$('#result').replaceWith('<div id="result" class="alert alert-danger">Failure: Item '+barcode+' belongs to another bundle</div>'); |
1790 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">Failure: Item '+barcode+' belongs to another bundle</div>'); |
1760 |
} |
1791 |
} |
1761 |
} else { |
1792 |
} else { |
1762 |
$('#result').replaceWith('<div id="result" class="alert alert-danger">Failure: Check the logs for details</div>'); |
1793 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">Failure: Check the logs for details</div>'); |
1763 |
} |
1794 |
} |
1764 |
$('#external_id').val('').focus(); |
1795 |
$('#external_id').val('').focus(); |
1765 |
}); |
1796 |
}); |
1766 |
}); |
1797 |
}); |
1767 |
|
1798 |
|
1768 |
$("#bundleItemsModal").on("hidden.bs.modal", function(e){ |
1799 |
$("#addToBundleModal").on("hidden.bs.modal", function(e){ |
1769 |
if ( bundle_changed ) { |
1800 |
if ( bundle_changed ) { |
1770 |
$('#bundle_table_'+bundle_form_active).DataTable({ 'retrieve': true }).ajax.reload(); |
1801 |
$('#bundle_table_'+bundle_form_active).DataTable({ 'retrieve': true }).ajax.reload(); |
1771 |
} |
1802 |
} |
Lines 1773-1778
Note that permanent location is a code, and location may be an authval.
Link Here
|
1773 |
bundle_changed = 0; |
1804 |
bundle_changed = 0; |
1774 |
}); |
1805 |
}); |
1775 |
|
1806 |
|
|
|
1807 |
$("#removeFromBundleModal").on("shown.bs.modal", function(e){ |
1808 |
var button = $(e.relatedTarget); |
1809 |
var item_id = button.data('item'); |
1810 |
$("#removeResult").replaceWith('<div id="removeResult"></div>'); |
1811 |
$("#removeFromBundleForm").attr('action', '/api/v1/items/' + item_id + '/bundled_items/'); |
1812 |
$("#rm_external_id").focus(); |
1813 |
bundle_changed = 0; |
1814 |
bundle_form_active = item_id; |
1815 |
}); |
1816 |
|
1817 |
$("#removeFromBundleForm").submit(function(event) { |
1818 |
|
1819 |
/* stop form from submitting normally */ |
1820 |
event.preventDefault(); |
1821 |
|
1822 |
/* get the action attribute from the <form action=""> element */ |
1823 |
var $form = $(this), |
1824 |
url = $form.attr('action'); |
1825 |
|
1826 |
var barcode = $('#rm_external_id').val(); |
1827 |
|
1828 |
/* Fetch itemnumber using rm_external_id */ |
1829 |
var itemReq = $.get('/api/v1/items', { q: JSON.stringify({ |
1830 |
external_id: barcode |
1831 |
}) }, null, "json"); |
1832 |
|
1833 |
var itemnumber; |
1834 |
itemReq.done(function(data) { |
1835 |
if (data.length === 1) { |
1836 |
itemnumber = data[0].item_id; |
1837 |
|
1838 |
/* Remove link using fetch itemnumber */ |
1839 |
var deleteReq = $.ajax( url + itemnumber, { |
1840 |
type : 'DELETE' |
1841 |
}); |
1842 |
|
1843 |
/* Report the results */ |
1844 |
deleteReq.done(function(data) { |
1845 |
var barcode = $('#rm_external_id').val(); |
1846 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-success">'+_("Success: Removed ")+barcode+'</div>'); |
1847 |
$('#rm_external_id').val('').focus(); |
1848 |
bundle_changed = 1; |
1849 |
}); |
1850 |
deleteReq.fail(function(data) { |
1851 |
var barcode = $('#rm_external_id').val(); |
1852 |
if ( data.status === 409 ) { |
1853 |
var response = data.responseJSON; |
1854 |
if ( response.key === "PRIMARY" ) { |
1855 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-warning">Warning: Item '+barcode+' already attached</div>'); |
1856 |
} else { |
1857 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-danger">Failure: Item '+barcode+' belongs to another bundle</div>'); |
1858 |
} |
1859 |
} else { |
1860 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-danger">Failure: Check the logs for details</div>'); |
1861 |
} |
1862 |
$('#rm_external_id').val('').focus(); |
1863 |
}); |
1864 |
} else { |
1865 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-danger">'+_("Failed: Barcode matched more than one item ")+barcode+'</div>'); |
1866 |
} |
1867 |
}); |
1868 |
itemReq.fail(function(data) { |
1869 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-danger">'+_("Failed: Item not found ")+barcode+'</div>'); |
1870 |
$('#rm_external_id').val('').focus(); |
1871 |
|
1872 |
}); |
1873 |
}); |
1874 |
|
1875 |
$("#removeFromBundleModal").on("hidden.bs.modal", function(e){ |
1876 |
if ( bundle_changed ) { |
1877 |
$('#bundle_table_'+bundle_form_active).DataTable({ 'retrieve': true }).ajax.reload(); |
1878 |
} |
1879 |
bundle_form_active = 0; |
1880 |
bundle_changed = 0; |
1881 |
}); |
1776 |
// End bundle handling |
1882 |
// End bundle handling |
1777 |
[% END %] |
1883 |
[% END %] |
1778 |
|
1884 |
|
1779 |
- |
|
|