-
+
+
+
[% END %]
[% MACRO jsinclude BLOCK %]
@@ -1417,7 +1446,9 @@ Note that permanent location is a code, and location may be an authval.
function createChild ( row, itemnumber ) {
// Toolbar
- var bundle_toolbar = $('
');
+ var bundle_toolbar = $('
');
+ bundle_toolbar.append('
Add to bundle');
+ bundle_toolbar.append('
Remove from bundle');
// This is the table we'll convert into a DataTable
var bundles_table = $('
');
@@ -1546,17 +1577,17 @@ Note that permanent location is a code, and location may be an authval.
var bundle_changed;
var bundle_form_active;
- $("#bundleItemsModal").on("shown.bs.modal", function(e){
+ $("#addToBundleModal").on("shown.bs.modal", function(e){
var button = $(e.relatedTarget);
var item_id = button.data('item');
- $("#result").replaceWith('
');
- $("#bundleItemsForm").attr('action', '/api/v1/items/' + item_id + '/bundled_items');
+ $("#addResult").replaceWith('
');
+ $("#addToBundleForm").attr('action', '/api/v1/items/' + item_id + '/bundled_items');
$("#external_id").focus();
bundle_changed = 0;
bundle_form_active = item_id;
});
- $("#bundleItemsForm").submit(function(event) {
+ $("#addToBundleForm").submit(function(event) {
/* stop form from submitting normally */
event.preventDefault();
@@ -1576,7 +1607,7 @@ Note that permanent location is a code, and location may be an authval.
/* Report the results */
posting.done(function(data) {
var barcode = $('#external_id').val();
- $('#result').replaceWith('
Success: Added '+barcode+'
');
+ $('#addResult').replaceWith('
Success: Added '+barcode+'
');
$('#external_id').val('').focus();
bundle_changed = 1;
});
@@ -1585,18 +1616,18 @@ Note that permanent location is a code, and location may be an authval.
if ( data.status === 409 ) {
var response = data.responseJSON;
if ( response.key === "PRIMARY" ) {
- $('#result').replaceWith('
Warning: Item '+barcode+' already attached
');
+ $('#addResult').replaceWith('
Warning: Item '+barcode+' already attached
');
} else {
- $('#result').replaceWith('
Failure: Item '+barcode+' belongs to another bundle
');
+ $('#addResult').replaceWith('
Failure: Item '+barcode+' belongs to another bundle
');
}
} else {
- $('#result').replaceWith('
Failure: Check the logs for details
');
+ $('#addResult').replaceWith('
Failure: Check the logs for details
');
}
$('#external_id').val('').focus();
});
});
- $("#bundleItemsModal").on("hidden.bs.modal", function(e){
+ $("#addToBundleModal").on("hidden.bs.modal", function(e){
if ( bundle_changed ) {
$('#bundle_table_'+bundle_form_active).DataTable({ 'retrieve': true }).ajax.reload();
}
@@ -1604,6 +1635,81 @@ Note that permanent location is a code, and location may be an authval.
bundle_changed = 0;
});
+ $("#removeFromBundleModal").on("shown.bs.modal", function(e){
+ var button = $(e.relatedTarget);
+ var item_id = button.data('item');
+ $("#removeResult").replaceWith('
');
+ $("#removeFromBundleForm").attr('action', '/api/v1/items/' + item_id + '/bundled_items/');
+ $("#rm_external_id").focus();
+ bundle_changed = 0;
+ bundle_form_active = item_id;
+ });
+
+ $("#removeFromBundleForm").submit(function(event) {
+
+ /* stop form from submitting normally */
+ event.preventDefault();
+
+ /* get the action attribute from the