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