|
Lines 1048-1063
Note that permanent location is a code, and location may be an authval.
Link Here
|
| 1048 |
[% END %] |
1048 |
[% END %] |
| 1049 |
|
1049 |
|
| 1050 |
[% IF bundlesEnabled %] |
1050 |
[% IF bundlesEnabled %] |
| 1051 |
<div class="modal" id="bundleItemsModal" tabindex="-1" role="dialog" aria-labelledby="bundleItemsLabel"> |
1051 |
<div class="modal" id="addToBundleModal" tabindex="-1" role="dialog" aria-labelledby="addToBundleLabel"> |
| 1052 |
<form id="bundleItemsForm" action=""> |
1052 |
<form id="addToBundleForm" action=""> |
| 1053 |
<div class="modal-dialog" role="document"> |
1053 |
<div class="modal-dialog" role="document"> |
| 1054 |
<div class="modal-content"> |
1054 |
<div class="modal-content"> |
| 1055 |
<div class="modal-header"> |
1055 |
<div class="modal-header"> |
| 1056 |
<button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button> |
1056 |
<button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button> |
| 1057 |
<h3 id="bundleItemsLabel">Add to bundle</h3> |
1057 |
<h3 id="addToBundleLabel">Add to bundle</h3> |
| 1058 |
</div> |
1058 |
</div> |
| 1059 |
<div class="modal-body"> |
1059 |
<div class="modal-body"> |
| 1060 |
<div id="result"></div> |
1060 |
<div id="addResult"></div> |
| 1061 |
<fieldset class="rows"> |
1061 |
<fieldset class="rows"> |
| 1062 |
<ol> |
1062 |
<ol> |
| 1063 |
<li> |
1063 |
<li> |
|
Lines 1076-1081
Note that permanent location is a code, and location may be an authval.
Link Here
|
| 1076 |
</div> |
1076 |
</div> |
| 1077 |
</form> |
1077 |
</form> |
| 1078 |
</div> |
1078 |
</div> |
|
|
1079 |
|
| 1080 |
<div class="modal" id="removeFromBundleModal" tabindex="-1" role="dialog" aria-labelledby="removeFromBundleLabel"> |
| 1081 |
<form id="removeFromBundleForm" action=""> |
| 1082 |
<div class="modal-dialog" role="document"> |
| 1083 |
<div class="modal-content"> |
| 1084 |
<div class="modal-header"> |
| 1085 |
<button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button> |
| 1086 |
<h3 id="removeFromBundleLabel">Remove from bundle</h3> |
| 1087 |
</div> |
| 1088 |
<div class="modal-body"> |
| 1089 |
<div id="removeResult"></div> |
| 1090 |
<fieldset class="rows"> |
| 1091 |
<ol> |
| 1092 |
<li> |
| 1093 |
<label class="required" for="external_id">Item barcode: </label> |
| 1094 |
<input type="text" id="rm_external_id" name="external_id" required="required"> |
| 1095 |
<span class="required">Required</span> |
| 1096 |
</li> |
| 1097 |
</ol> |
| 1098 |
</fieldset> |
| 1099 |
</div> |
| 1100 |
<div class="modal-footer"> |
| 1101 |
<button type="submit" class="btn btn-default">Submit</button> |
| 1102 |
<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button> |
| 1103 |
</div> |
| 1104 |
</div> |
| 1105 |
</div> |
| 1106 |
</form> |
| 1107 |
</div> |
| 1079 |
[% END %] |
1108 |
[% END %] |
| 1080 |
|
1109 |
|
| 1081 |
[% MACRO jsinclude BLOCK %] |
1110 |
[% MACRO jsinclude BLOCK %] |
|
Lines 1399-1405
Note that permanent location is a code, and location may be an authval.
Link Here
|
| 1399 |
function createChild ( row, itemnumber ) { |
1428 |
function createChild ( row, itemnumber ) { |
| 1400 |
|
1429 |
|
| 1401 |
// Toolbar |
1430 |
// Toolbar |
| 1402 |
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>'); |
1431 |
var bundle_toolbar = $('<div id="toolbar" class="btn-toolbar"></div>'); |
|
|
1432 |
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>'); |
| 1433 |
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>'); |
| 1403 |
|
1434 |
|
| 1404 |
// This is the table we'll convert into a DataTable |
1435 |
// This is the table we'll convert into a DataTable |
| 1405 |
var bundles_table = $('<table class="display tbundle" data-itemnumber="'+itemnumber+'" id="bundle_table_'+itemnumber+'" width="100%"/>'); |
1436 |
var bundles_table = $('<table class="display tbundle" data-itemnumber="'+itemnumber+'" id="bundle_table_'+itemnumber+'" width="100%"/>'); |
|
Lines 1525-1541
Note that permanent location is a code, and location may be an authval.
Link Here
|
| 1525 |
|
1556 |
|
| 1526 |
var bundle_changed; |
1557 |
var bundle_changed; |
| 1527 |
var bundle_form_active; |
1558 |
var bundle_form_active; |
| 1528 |
$("#bundleItemsModal").on("shown.bs.modal", function(e){ |
1559 |
$("#addToBundleModal").on("shown.bs.modal", function(e){ |
| 1529 |
var button = $(e.relatedTarget); |
1560 |
var button = $(e.relatedTarget); |
| 1530 |
var item_id = button.data('item'); |
1561 |
var item_id = button.data('item'); |
| 1531 |
$("#result").replaceWith('<div id="result"></div>'); |
1562 |
$("#addResult").replaceWith('<div id="addResult"></div>'); |
| 1532 |
$("#bundleItemsForm").attr('action', '/api/v1/items/' + item_id + '/bundled_items'); |
1563 |
$("#addToBundleForm").attr('action', '/api/v1/items/' + item_id + '/bundled_items'); |
| 1533 |
$("#external_id").focus(); |
1564 |
$("#external_id").focus(); |
| 1534 |
bundle_changed = 0; |
1565 |
bundle_changed = 0; |
| 1535 |
bundle_form_active = item_id; |
1566 |
bundle_form_active = item_id; |
| 1536 |
}); |
1567 |
}); |
| 1537 |
|
1568 |
|
| 1538 |
$("#bundleItemsForm").submit(function(event) { |
1569 |
$("#addToBundleForm").submit(function(event) { |
| 1539 |
|
1570 |
|
| 1540 |
/* stop form from submitting normally */ |
1571 |
/* stop form from submitting normally */ |
| 1541 |
event.preventDefault(); |
1572 |
event.preventDefault(); |
|
Lines 1552-1558
Note that permanent location is a code, and location may be an authval.
Link Here
|
| 1552 |
/* Report the results */ |
1583 |
/* Report the results */ |
| 1553 |
posting.done(function(data) { |
1584 |
posting.done(function(data) { |
| 1554 |
var barcode = $('#external_id').val(); |
1585 |
var barcode = $('#external_id').val(); |
| 1555 |
$('#result').replaceWith('<div id="result" class="alert alert-success">Success: Added '+barcode+'</div>'); |
1586 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-success">Success: Added '+barcode+'</div>'); |
| 1556 |
$('#external_id').val('').focus(); |
1587 |
$('#external_id').val('').focus(); |
| 1557 |
bundle_changed = 1; |
1588 |
bundle_changed = 1; |
| 1558 |
}); |
1589 |
}); |
|
Lines 1561-1578
Note that permanent location is a code, and location may be an authval.
Link Here
|
| 1561 |
if ( data.status === 409 ) { |
1592 |
if ( data.status === 409 ) { |
| 1562 |
var response = data.responseJSON; |
1593 |
var response = data.responseJSON; |
| 1563 |
if ( response.key === "PRIMARY" ) { |
1594 |
if ( response.key === "PRIMARY" ) { |
| 1564 |
$('#result').replaceWith('<div id="result" class="alert alert-warning">Warning: Item '+barcode+' already attached</div>'); |
1595 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-warning">Warning: Item '+barcode+' already attached</div>'); |
| 1565 |
} else { |
1596 |
} else { |
| 1566 |
$('#result').replaceWith('<div id="result" class="alert alert-danger">Failure: Item '+barcode+' belongs to another bundle</div>'); |
1597 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">Failure: Item '+barcode+' belongs to another bundle</div>'); |
| 1567 |
} |
1598 |
} |
| 1568 |
} else { |
1599 |
} else { |
| 1569 |
$('#result').replaceWith('<div id="result" class="alert alert-danger">Failure: Check the logs for details</div>'); |
1600 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">Failure: Check the logs for details</div>'); |
| 1570 |
} |
1601 |
} |
| 1571 |
$('#external_id').val('').focus(); |
1602 |
$('#external_id').val('').focus(); |
| 1572 |
}); |
1603 |
}); |
| 1573 |
}); |
1604 |
}); |
| 1574 |
|
1605 |
|
| 1575 |
$("#bundleItemsModal").on("hidden.bs.modal", function(e){ |
1606 |
$("#addToBundleModal").on("hidden.bs.modal", function(e){ |
| 1576 |
if ( bundle_changed ) { |
1607 |
if ( bundle_changed ) { |
| 1577 |
$('#bundle_table_'+bundle_form_active).DataTable({ 'retrieve': true }).ajax.reload(); |
1608 |
$('#bundle_table_'+bundle_form_active).DataTable({ 'retrieve': true }).ajax.reload(); |
| 1578 |
} |
1609 |
} |
|
Lines 1580-1585
Note that permanent location is a code, and location may be an authval.
Link Here
|
| 1580 |
bundle_changed = 0; |
1611 |
bundle_changed = 0; |
| 1581 |
}); |
1612 |
}); |
| 1582 |
|
1613 |
|
|
|
1614 |
$("#removeFromBundleModal").on("shown.bs.modal", function(e){ |
| 1615 |
var button = $(e.relatedTarget); |
| 1616 |
var item_id = button.data('item'); |
| 1617 |
$("#removeResult").replaceWith('<div id="removeResult"></div>'); |
| 1618 |
$("#removeFromBundleForm").attr('action', '/api/v1/items/' + item_id + '/bundled_items/'); |
| 1619 |
$("#rm_external_id").focus(); |
| 1620 |
bundle_changed = 0; |
| 1621 |
bundle_form_active = item_id; |
| 1622 |
}); |
| 1623 |
|
| 1624 |
$("#removeFromBundleForm").submit(function(event) { |
| 1625 |
|
| 1626 |
/* stop form from submitting normally */ |
| 1627 |
event.preventDefault(); |
| 1628 |
|
| 1629 |
/* get the action attribute from the <form action=""> element */ |
| 1630 |
var $form = $(this), |
| 1631 |
url = $form.attr('action'); |
| 1632 |
|
| 1633 |
var barcode = $('#rm_external_id').val(); |
| 1634 |
|
| 1635 |
/* Fetch itemnumber using rm_external_id */ |
| 1636 |
var itemReq = $.get('/api/v1/items', { q: JSON.stringify({ |
| 1637 |
external_id: barcode |
| 1638 |
}) }, null, "json"); |
| 1639 |
|
| 1640 |
var itemnumber; |
| 1641 |
itemReq.done(function(data) { |
| 1642 |
if (data.length === 1) { |
| 1643 |
itemnumber = data[0].item_id; |
| 1644 |
|
| 1645 |
/* Remove link using fetch itemnumber */ |
| 1646 |
var deleteReq = $.ajax( url + itemnumber, { |
| 1647 |
type : 'DELETE' |
| 1648 |
}); |
| 1649 |
|
| 1650 |
/* Report the results */ |
| 1651 |
deleteReq.done(function(data) { |
| 1652 |
var barcode = $('#rm_external_id').val(); |
| 1653 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-success">'+_("Success: Removed ")+barcode+'</div>'); |
| 1654 |
$('#rm_external_id').val('').focus(); |
| 1655 |
bundle_changed = 1; |
| 1656 |
}); |
| 1657 |
deleteReq.fail(function(data) { |
| 1658 |
var barcode = $('#rm_external_id').val(); |
| 1659 |
if ( data.status === 409 ) { |
| 1660 |
var response = data.responseJSON; |
| 1661 |
if ( response.key === "PRIMARY" ) { |
| 1662 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-warning">Warning: Item '+barcode+' already attached</div>'); |
| 1663 |
} else { |
| 1664 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-danger">Failure: Item '+barcode+' belongs to another bundle</div>'); |
| 1665 |
} |
| 1666 |
} else { |
| 1667 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-danger">Failure: Check the logs for details</div>'); |
| 1668 |
} |
| 1669 |
$('#rm_external_id').val('').focus(); |
| 1670 |
}); |
| 1671 |
} else { |
| 1672 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-danger">'+_("Failed: Barcode matched more than one item ")+barcode+'</div>'); |
| 1673 |
} |
| 1674 |
}); |
| 1675 |
itemReq.fail(function(data) { |
| 1676 |
$('#removeResult').replaceWith('<div id="removeResult" class="alert alert-danger">'+_("Failed: Item not found ")+barcode+'</div>'); |
| 1677 |
$('#rm_external_id').val('').focus(); |
| 1678 |
|
| 1679 |
}); |
| 1680 |
}); |
| 1681 |
|
| 1682 |
$("#removeFromBundleModal").on("hidden.bs.modal", function(e){ |
| 1683 |
if ( bundle_changed ) { |
| 1684 |
$('#bundle_table_'+bundle_form_active).DataTable({ 'retrieve': true }).ajax.reload(); |
| 1685 |
} |
| 1686 |
bundle_form_active = 0; |
| 1687 |
bundle_changed = 0; |
| 1688 |
}); |
| 1583 |
// End bundle handling |
1689 |
// End bundle handling |
| 1584 |
[% END %] |
1690 |
[% END %] |
| 1585 |
|
1691 |
|
| 1586 |
- |
|
|