Lines 1068-1083
Note that permanent location is a code, and location may be an authval.
Link Here
|
1068 |
[% END %] |
1068 |
[% END %] |
1069 |
|
1069 |
|
1070 |
[% IF bundlesEnabled %] |
1070 |
[% IF bundlesEnabled %] |
1071 |
<div class="modal" id="bundleItemsModal" tabindex="-1" role="dialog" aria-labelledby="bundleItemsLabel"> |
1071 |
<div class="modal" id="addToBundleModal" tabindex="-1" role="dialog" aria-labelledby="addToBundleLabel"> |
1072 |
<form id="bundleItemsForm" action=""> |
1072 |
<form id="addToBundleForm" action=""> |
1073 |
<div class="modal-dialog" role="document"> |
1073 |
<div class="modal-dialog" role="document"> |
1074 |
<div class="modal-content"> |
1074 |
<div class="modal-content"> |
1075 |
<div class="modal-header"> |
1075 |
<div class="modal-header"> |
1076 |
<button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button> |
1076 |
<button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button> |
1077 |
<h3 id="bundleItemsLabel">Add to bundle</h3> |
1077 |
<h3 id="addToBundleLabel">Add to bundle</h3> |
1078 |
</div> |
1078 |
</div> |
1079 |
<div class="modal-body"> |
1079 |
<div class="modal-body"> |
1080 |
<div id="result"></div> |
1080 |
<div id="addResult"></div> |
1081 |
<fieldset class="rows"> |
1081 |
<fieldset class="rows"> |
1082 |
<ol> |
1082 |
<ol> |
1083 |
<li> |
1083 |
<li> |
Lines 1096-1101
Note that permanent location is a code, and location may be an authval.
Link Here
|
1096 |
</div> |
1096 |
</div> |
1097 |
</form> |
1097 |
</form> |
1098 |
</div> |
1098 |
</div> |
|
|
1099 |
|
1100 |
<div class="modal" id="removeFromBundleModal" tabindex="-1" role="dialog" aria-labelledby="removeFromBundleLabel"> |
1101 |
<form id="removeFromBundleForm" action=""> |
1102 |
<div class="modal-dialog" role="document"> |
1103 |
<div class="modal-content"> |
1104 |
<div class="modal-header"> |
1105 |
<button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button> |
1106 |
<h3 id="removeFromBundleLabel">Remove from bundle</h3> |
1107 |
</div> |
1108 |
<div class="modal-body"> |
1109 |
<div id="removeResult"></div> |
1110 |
<fieldset class="rows"> |
1111 |
<ol> |
1112 |
<li> |
1113 |
<label class="required" for="external_id">Item barcode: </label> |
1114 |
<input type="text" id="rm_external_id" name="external_id" required="required"> |
1115 |
<span class="required">Required</span> |
1116 |
</li> |
1117 |
</ol> |
1118 |
</fieldset> |
1119 |
</div> |
1120 |
<div class="modal-footer"> |
1121 |
<button type="submit" class="btn btn-default">Submit</button> |
1122 |
<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button> |
1123 |
</div> |
1124 |
</div> |
1125 |
</div> |
1126 |
</form> |
1127 |
</div> |
1099 |
[% END %] |
1128 |
[% END %] |
1100 |
|
1129 |
|
1101 |
[% MACRO jsinclude BLOCK %] |
1130 |
[% MACRO jsinclude BLOCK %] |
Lines 1423-1429
Note that permanent location is a code, and location may be an authval.
Link Here
|
1423 |
function createChild ( row, itemnumber ) { |
1452 |
function createChild ( row, itemnumber ) { |
1424 |
|
1453 |
|
1425 |
// Toolbar |
1454 |
// Toolbar |
1426 |
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>'); |
1455 |
var bundle_toolbar = $('<div id="toolbar" class="btn-toolbar"></div>'); |
|
|
1456 |
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>'); |
1457 |
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>'); |
1427 |
|
1458 |
|
1428 |
// This is the table we'll convert into a DataTable |
1459 |
// This is the table we'll convert into a DataTable |
1429 |
var bundles_table = $('<table class="display tbundle" data-itemnumber="'+itemnumber+'" id="bundle_table_'+itemnumber+'" width="100%"/>'); |
1460 |
var bundles_table = $('<table class="display tbundle" data-itemnumber="'+itemnumber+'" id="bundle_table_'+itemnumber+'" width="100%"/>'); |
Lines 1552-1568
Note that permanent location is a code, and location may be an authval.
Link Here
|
1552 |
|
1583 |
|
1553 |
var bundle_changed; |
1584 |
var bundle_changed; |
1554 |
var bundle_form_active; |
1585 |
var bundle_form_active; |
1555 |
$("#bundleItemsModal").on("shown.bs.modal", function(e){ |
1586 |
$("#addToBundleModal").on("shown.bs.modal", function(e){ |
1556 |
var button = $(e.relatedTarget); |
1587 |
var button = $(e.relatedTarget); |
1557 |
var item_id = button.data('item'); |
1588 |
var item_id = button.data('item'); |
1558 |
$("#result").replaceWith('<div id="result"></div>'); |
1589 |
$("#addResult").replaceWith('<div id="addResult"></div>'); |
1559 |
$("#bundleItemsForm").attr('action', '/api/v1/items/' + item_id + '/bundled_items'); |
1590 |
$("#addToBundleForm").attr('action', '/api/v1/items/' + item_id + '/bundled_items'); |
1560 |
$("#external_id").focus(); |
1591 |
$("#external_id").focus(); |
1561 |
bundle_changed = 0; |
1592 |
bundle_changed = 0; |
1562 |
bundle_form_active = item_id; |
1593 |
bundle_form_active = item_id; |
1563 |
}); |
1594 |
}); |
1564 |
|
1595 |
|
1565 |
$("#bundleItemsForm").submit(function(event) { |
1596 |
$("#addToBundleForm").submit(function(event) { |
1566 |
|
1597 |
|
1567 |
/* stop form from submitting normally */ |
1598 |
/* stop form from submitting normally */ |
1568 |
event.preventDefault(); |
1599 |
event.preventDefault(); |
Lines 1582-1588
Note that permanent location is a code, and location may be an authval.
Link Here
|
1582 |
/* Report the results */ |
1613 |
/* Report the results */ |
1583 |
posting.done(function(data) { |
1614 |
posting.done(function(data) { |
1584 |
var barcode = $('#external_id').val(); |
1615 |
var barcode = $('#external_id').val(); |
1585 |
$('#result').replaceWith('<div id="result" class="alert alert-success">Success: Added '+barcode+'</div>'); |
1616 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-success">Success: Added '+barcode+'</div>'); |
1586 |
$('#external_id').val('').focus(); |
1617 |
$('#external_id').val('').focus(); |
1587 |
bundle_changed = 1; |
1618 |
bundle_changed = 1; |
1588 |
}); |
1619 |
}); |
Lines 1591-1608
Note that permanent location is a code, and location may be an authval.
Link Here
|
1591 |
if ( data.status === 409 ) { |
1622 |
if ( data.status === 409 ) { |
1592 |
var response = data.responseJSON; |
1623 |
var response = data.responseJSON; |
1593 |
if ( response.key === "PRIMARY" ) { |
1624 |
if ( response.key === "PRIMARY" ) { |
1594 |
$('#result').replaceWith('<div id="result" class="alert alert-warning">Warning: Item '+barcode+' already attached</div>'); |
1625 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-warning">Warning: Item '+barcode+' already attached</div>'); |
1595 |
} else { |
1626 |
} else { |
1596 |
$('#result').replaceWith('<div id="result" class="alert alert-danger">Failure: Item '+barcode+' belongs to another bundle</div>'); |
1627 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">Failure: Item '+barcode+' belongs to another bundle</div>'); |
1597 |
} |
1628 |
} |
1598 |
} else { |
1629 |
} else { |
1599 |
$('#result').replaceWith('<div id="result" class="alert alert-danger">Failure: Check the logs for details</div>'); |
1630 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">Failure: Check the logs for details</div>'); |
1600 |
} |
1631 |
} |
1601 |
$('#external_id').val('').focus(); |
1632 |
$('#external_id').val('').focus(); |
1602 |
}); |
1633 |
}); |
1603 |
}); |
1634 |
}); |
1604 |
|
1635 |
|
1605 |
$("#bundleItemsModal").on("hidden.bs.modal", function(e){ |
1636 |
$("#addToBundleModal").on("hidden.bs.modal", function(e){ |
1606 |
if ( bundle_changed ) { |
1637 |
if ( bundle_changed ) { |
1607 |
$('#bundle_table_'+bundle_form_active).DataTable({ 'retrieve': true }).ajax.reload(); |
1638 |
$('#bundle_table_'+bundle_form_active).DataTable({ 'retrieve': true }).ajax.reload(); |
1608 |
} |
1639 |
} |
Lines 1610-1615
Note that permanent location is a code, and location may be an authval.
Link Here
|
1610 |
bundle_changed = 0; |
1641 |
bundle_changed = 0; |
1611 |
}); |
1642 |
}); |
1612 |
|
1643 |
|
|
|
1644 |
$("#removeFromBundleModal").on("shown.bs.modal", function(e){ |
1645 |
var button = $(e.relatedTarget); |
1646 |
var item_id = button.data('item'); |
1647 |
$("#removeResult").replaceWith('<div id="removeResult"></div>'); |
1648 |
$("#removeFromBundleForm").attr('action', '/api/v1/items/' + item_id + '/bundled_items/'); |
1649 |
$("#rm_external_id").focus(); |
1650 |
bundle_changed = 0; |
1651 |
bundle_form_active = item_id; |
1652 |
}); |
1653 |
|
1654 |
$("#removeFromBundleForm").submit(function(event) { |
1655 |
|
1656 |
/* stop form from submitting normally */ |
1657 |
event.preventDefault(); |
1658 |
|
1659 |
/* get the action attribute from the <form action=""> element */ |
1660 |
var $form = $(this), |
1661 |
url = $form.attr('action'); |
1662 |
|
1663 |
var barcode = $('#rm_external_id').val(); |
1664 |
|
1665 |
/* Fetch itemnumber using rm_external_id */ |
1666 |
var itemReq = $.get('/api/v1/items', { q: JSON.stringify({ |
1667 |
external_id: barcode |
1668 |
}) }, null, "json"); |
1669 |
|
1670 |
var itemnumber; |
1671 |
itemReq.done(function(data) { |
1672 |
if (data.length === 1) { |
1673 |
itemnumber = data[0].item_id; |
1674 |
|
1675 |
/* Remove link using fetch itemnumber */ |
1676 |
var deleteReq = $.ajax( url + itemnumber, { |
1677 |
type : 'DELETE' |
1678 |
}); |
1679 |
|
1680 |
/* Report the results */ |
1681 |
deleteReq.done(function(data) { |
1682 |
var barcode = $('#rm_external_id').val(); |
1683 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-success">'+_("Success: Removed ")+barcode+'</div>'); |
1684 |
$('#rm_external_id').val('').focus(); |
1685 |
bundle_changed = 1; |
1686 |
}); |
1687 |
deleteReq.fail(function(data) { |
1688 |
var barcode = $('#rm_external_id').val(); |
1689 |
if ( data.status === 409 ) { |
1690 |
var response = data.responseJSON; |
1691 |
if ( response.key === "PRIMARY" ) { |
1692 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-warning">Warning: Item '+barcode+' already attached</div>'); |
1693 |
} else { |
1694 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-danger">Failure: Item '+barcode+' belongs to another bundle</div>'); |
1695 |
} |
1696 |
} else { |
1697 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-danger">Failure: Check the logs for details</div>'); |
1698 |
} |
1699 |
$('#rm_external_id').val('').focus(); |
1700 |
}); |
1701 |
} else { |
1702 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-danger">'+_("Failed: Barcode matched more than one item ")+barcode+'</div>'); |
1703 |
} |
1704 |
}); |
1705 |
itemReq.fail(function(data) { |
1706 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-danger">'+_("Failed: Item not found ")+barcode+'</div>'); |
1707 |
$('#rm_external_id').val('').focus(); |
1708 |
|
1709 |
}); |
1710 |
}); |
1711 |
|
1712 |
$("#removeFromBundleModal").on("hidden.bs.modal", function(e){ |
1713 |
if ( bundle_changed ) { |
1714 |
$('#bundle_table_'+bundle_form_active).DataTable({ 'retrieve': true }).ajax.reload(); |
1715 |
} |
1716 |
bundle_form_active = 0; |
1717 |
bundle_changed = 0; |
1718 |
}); |
1613 |
// End bundle handling |
1719 |
// End bundle handling |
1614 |
[% END %] |
1720 |
[% END %] |
1615 |
|
1721 |
|
1616 |
- |
|
|