Lines 1037-1052
Note that permanent location is a code, and location may be an authval.
Link Here
|
1037 |
[% END %] |
1037 |
[% END %] |
1038 |
|
1038 |
|
1039 |
[% IF bundlesEnabled %] |
1039 |
[% IF bundlesEnabled %] |
1040 |
<div class="modal" id="bundleItemsModal" tabindex="-1" role="dialog" aria-labelledby="bundleItemsLabel"> |
1040 |
<div class="modal" id="addToBundleModal" tabindex="-1" role="dialog" aria-labelledby="addToBundleLabel"> |
1041 |
<form id="bundleItemsForm" action=""> |
1041 |
<form id="addToBundleForm" action=""> |
1042 |
<div class="modal-dialog" role="document"> |
1042 |
<div class="modal-dialog" role="document"> |
1043 |
<div class="modal-content"> |
1043 |
<div class="modal-content"> |
1044 |
<div class="modal-header"> |
1044 |
<div class="modal-header"> |
1045 |
<button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button> |
1045 |
<button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button> |
1046 |
<h3 id="bundleItemsLabel">Add to bundle</h3> |
1046 |
<h3 id="addToBundleLabel">Add to bundle</h3> |
1047 |
</div> |
1047 |
</div> |
1048 |
<div class="modal-body"> |
1048 |
<div class="modal-body"> |
1049 |
<div id="result"></div> |
1049 |
<div id="addResult"></div> |
1050 |
<fieldset class="rows"> |
1050 |
<fieldset class="rows"> |
1051 |
<ol> |
1051 |
<ol> |
1052 |
<li> |
1052 |
<li> |
Lines 1065-1070
Note that permanent location is a code, and location may be an authval.
Link Here
|
1065 |
</div> |
1065 |
</div> |
1066 |
</form> |
1066 |
</form> |
1067 |
</div> |
1067 |
</div> |
|
|
1068 |
|
1069 |
<div class="modal" id="removeFromBundleModal" tabindex="-1" role="dialog" aria-labelledby="removeFromBundleLabel"> |
1070 |
<form id="removeFromBundleForm" action=""> |
1071 |
<div class="modal-dialog" role="document"> |
1072 |
<div class="modal-content"> |
1073 |
<div class="modal-header"> |
1074 |
<button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button> |
1075 |
<h3 id="removeFromBundleLabel">Remove from bundle</h3> |
1076 |
</div> |
1077 |
<div class="modal-body"> |
1078 |
<div id="removeResult"></div> |
1079 |
<fieldset class="rows"> |
1080 |
<ol> |
1081 |
<li> |
1082 |
<label class="required" for="external_id">Item barcode: </label> |
1083 |
<input type="text" id="rm_external_id" name="external_id" required="required"> |
1084 |
<span class="required">Required</span> |
1085 |
</li> |
1086 |
</ol> |
1087 |
</fieldset> |
1088 |
</div> |
1089 |
<div class="modal-footer"> |
1090 |
<button type="submit" class="btn btn-default">Submit</button> |
1091 |
<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button> |
1092 |
</div> |
1093 |
</div> |
1094 |
</div> |
1095 |
</form> |
1096 |
</div> |
1068 |
[% END %] |
1097 |
[% END %] |
1069 |
|
1098 |
|
1070 |
[% MACRO jsinclude BLOCK %] |
1099 |
[% MACRO jsinclude BLOCK %] |
Lines 1384-1390
Note that permanent location is a code, and location may be an authval.
Link Here
|
1384 |
function createChild ( row, itemnumber ) { |
1413 |
function createChild ( row, itemnumber ) { |
1385 |
|
1414 |
|
1386 |
// Toolbar |
1415 |
// Toolbar |
1387 |
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>'); |
1416 |
var bundle_toolbar = $('<div id="toolbar" class="btn-toolbar"></div>'); |
|
|
1417 |
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>'); |
1418 |
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>'); |
1388 |
|
1419 |
|
1389 |
// This is the table we'll convert into a DataTable |
1420 |
// This is the table we'll convert into a DataTable |
1390 |
var bundles_table = $('<table class="display tbundle" data-itemnumber="'+itemnumber+'" id="bundle_table_'+itemnumber+'" width="100%"/>'); |
1421 |
var bundles_table = $('<table class="display tbundle" data-itemnumber="'+itemnumber+'" id="bundle_table_'+itemnumber+'" width="100%"/>'); |
Lines 1510-1526
Note that permanent location is a code, and location may be an authval.
Link Here
|
1510 |
|
1541 |
|
1511 |
var bundle_changed; |
1542 |
var bundle_changed; |
1512 |
var bundle_form_active; |
1543 |
var bundle_form_active; |
1513 |
$("#bundleItemsModal").on("shown.bs.modal", function(e){ |
1544 |
$("#addToBundleModal").on("shown.bs.modal", function(e){ |
1514 |
var button = $(e.relatedTarget); |
1545 |
var button = $(e.relatedTarget); |
1515 |
var item_id = button.data('item'); |
1546 |
var item_id = button.data('item'); |
1516 |
$("#result").replaceWith('<div id="result"></div>'); |
1547 |
$("#addResult").replaceWith('<div id="addResult"></div>'); |
1517 |
$("#bundleItemsForm").attr('action', '/api/v1/items/' + item_id + '/bundled_items'); |
1548 |
$("#addToBundleForm").attr('action', '/api/v1/items/' + item_id + '/bundled_items'); |
1518 |
$("#external_id").focus(); |
1549 |
$("#external_id").focus(); |
1519 |
bundle_changed = 0; |
1550 |
bundle_changed = 0; |
1520 |
bundle_form_active = item_id; |
1551 |
bundle_form_active = item_id; |
1521 |
}); |
1552 |
}); |
1522 |
|
1553 |
|
1523 |
$("#bundleItemsForm").submit(function(event) { |
1554 |
$("#addToBundleForm").submit(function(event) { |
1524 |
|
1555 |
|
1525 |
/* stop form from submitting normally */ |
1556 |
/* stop form from submitting normally */ |
1526 |
event.preventDefault(); |
1557 |
event.preventDefault(); |
Lines 1537-1543
Note that permanent location is a code, and location may be an authval.
Link Here
|
1537 |
/* Report the results */ |
1568 |
/* Report the results */ |
1538 |
posting.done(function(data) { |
1569 |
posting.done(function(data) { |
1539 |
var barcode = $('#external_id').val(); |
1570 |
var barcode = $('#external_id').val(); |
1540 |
$('#result').replaceWith('<div id="result" class="alert alert-success">Success: Added '+barcode+'</div>'); |
1571 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-success">Success: Added '+barcode+'</div>'); |
1541 |
$('#external_id').val('').focus(); |
1572 |
$('#external_id').val('').focus(); |
1542 |
bundle_changed = 1; |
1573 |
bundle_changed = 1; |
1543 |
}); |
1574 |
}); |
Lines 1546-1563
Note that permanent location is a code, and location may be an authval.
Link Here
|
1546 |
if ( data.status === 409 ) { |
1577 |
if ( data.status === 409 ) { |
1547 |
var response = data.responseJSON; |
1578 |
var response = data.responseJSON; |
1548 |
if ( response.key === "PRIMARY" ) { |
1579 |
if ( response.key === "PRIMARY" ) { |
1549 |
$('#result').replaceWith('<div id="result" class="alert alert-warning">Warning: Item '+barcode+' already attached</div>'); |
1580 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-warning">Warning: Item '+barcode+' already attached</div>'); |
1550 |
} else { |
1581 |
} else { |
1551 |
$('#result').replaceWith('<div id="result" class="alert alert-danger">Failure: Item '+barcode+' belongs to another bundle</div>'); |
1582 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">Failure: Item '+barcode+' belongs to another bundle</div>'); |
1552 |
} |
1583 |
} |
1553 |
} else { |
1584 |
} else { |
1554 |
$('#result').replaceWith('<div id="result" class="alert alert-danger">Failure: Check the logs for details</div>'); |
1585 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">Failure: Check the logs for details</div>'); |
1555 |
} |
1586 |
} |
1556 |
$('#external_id').val('').focus(); |
1587 |
$('#external_id').val('').focus(); |
1557 |
}); |
1588 |
}); |
1558 |
}); |
1589 |
}); |
1559 |
|
1590 |
|
1560 |
$("#bundleItemsModal").on("hidden.bs.modal", function(e){ |
1591 |
$("#addToBundleModal").on("hidden.bs.modal", function(e){ |
1561 |
if ( bundle_changed ) { |
1592 |
if ( bundle_changed ) { |
1562 |
$('#bundle_table_'+bundle_form_active).DataTable({ 'retrieve': true }).ajax.reload(); |
1593 |
$('#bundle_table_'+bundle_form_active).DataTable({ 'retrieve': true }).ajax.reload(); |
1563 |
} |
1594 |
} |
Lines 1565-1570
Note that permanent location is a code, and location may be an authval.
Link Here
|
1565 |
bundle_changed = 0; |
1596 |
bundle_changed = 0; |
1566 |
}); |
1597 |
}); |
1567 |
|
1598 |
|
|
|
1599 |
$("#removeFromBundleModal").on("shown.bs.modal", function(e){ |
1600 |
var button = $(e.relatedTarget); |
1601 |
var item_id = button.data('item'); |
1602 |
$("#removeResult").replaceWith('<div id="removeResult"></div>'); |
1603 |
$("#removeFromBundleForm").attr('action', '/api/v1/items/' + item_id + '/bundled_items/'); |
1604 |
$("#rm_external_id").focus(); |
1605 |
bundle_changed = 0; |
1606 |
bundle_form_active = item_id; |
1607 |
}); |
1608 |
|
1609 |
$("#removeFromBundleForm").submit(function(event) { |
1610 |
|
1611 |
/* stop form from submitting normally */ |
1612 |
event.preventDefault(); |
1613 |
|
1614 |
/* get the action attribute from the <form action=""> element */ |
1615 |
var $form = $(this), |
1616 |
url = $form.attr('action'); |
1617 |
|
1618 |
var barcode = $('#rm_external_id').val(); |
1619 |
|
1620 |
/* Fetch itemnumber using rm_external_id */ |
1621 |
var itemReq = $.get('/api/v1/items', { q: JSON.stringify({ |
1622 |
external_id: barcode |
1623 |
}) }, null, "json"); |
1624 |
|
1625 |
var itemnumber; |
1626 |
itemReq.done(function(data) { |
1627 |
if (data.length === 1) { |
1628 |
itemnumber = data[0].item_id; |
1629 |
|
1630 |
/* Remove link using fetch itemnumber */ |
1631 |
var deleteReq = $.ajax( url + itemnumber, { |
1632 |
type : 'DELETE' |
1633 |
}); |
1634 |
|
1635 |
/* Report the results */ |
1636 |
deleteReq.done(function(data) { |
1637 |
var barcode = $('#rm_external_id').val(); |
1638 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-success">'+_("Success: Removed ")+barcode+'</div>'); |
1639 |
$('#rm_external_id').val('').focus(); |
1640 |
bundle_changed = 1; |
1641 |
}); |
1642 |
deleteReq.fail(function(data) { |
1643 |
var barcode = $('#rm_external_id').val(); |
1644 |
if ( data.status === 409 ) { |
1645 |
var response = data.responseJSON; |
1646 |
if ( response.key === "PRIMARY" ) { |
1647 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-warning">Warning: Item '+barcode+' already attached</div>'); |
1648 |
} else { |
1649 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-danger">Failure: Item '+barcode+' belongs to another bundle</div>'); |
1650 |
} |
1651 |
} else { |
1652 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-danger">Failure: Check the logs for details</div>'); |
1653 |
} |
1654 |
$('#rm_external_id').val('').focus(); |
1655 |
}); |
1656 |
} else { |
1657 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-danger">'+_("Failed: Barcode matched more than one item ")+barcode+'</div>'); |
1658 |
} |
1659 |
}); |
1660 |
itemReq.fail(function(data) { |
1661 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-danger">'+_("Failed: Item not found ")+barcode+'</div>'); |
1662 |
$('#rm_external_id').val('').focus(); |
1663 |
|
1664 |
}); |
1665 |
}); |
1666 |
|
1667 |
$("#removeFromBundleModal").on("hidden.bs.modal", function(e){ |
1668 |
if ( bundle_changed ) { |
1669 |
$('#bundle_table_'+bundle_form_active).DataTable({ 'retrieve': true }).ajax.reload(); |
1670 |
} |
1671 |
bundle_form_active = 0; |
1672 |
bundle_changed = 0; |
1673 |
}); |
1568 |
// End bundle handling |
1674 |
// End bundle handling |
1569 |
[% END %] |
1675 |
[% END %] |
1570 |
|
1676 |
|
1571 |
- |
|
|