<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/grid.js"></script>
<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/ui.js"></script>
<script src="[% ctx.media_prefix %]/js/ui/default/staff/cat/bucket/copy/app.js"></script>
+<script>
+ angular.module('egCoreMod').run(['egStrings', function(s) {
+ s.CONFIRM_DELETE_COPY_BUCKET_ITEMS_FROM_CATALOG =
+ "[% l('Are you sure you want to delete all items in bucket from catalog?') %]";
+ }])
+</script>
[% END %]
<!-- using native Bootstrap taps because of limitations
<eg-grid-action label="[% l('Remove Selected Copies') %]"
handler="detachCopies"></eg-grid-action>
+ <eg-grid-action label="[% l('Delete All from Catalog') %]"
+ handler="deleteCopiesFromCatalog"></eg-grid-action>
<eg-grid-field path="id" required hidden></eg-grid-field>
<eg-grid-field path="call_number.record.id" required hidden></eg-grid-field>
}])
.controller('ViewCtrl',
- ['$scope','$q','$routeParams','bucketSvc',
-function($scope, $q , $routeParams, bucketSvc) {
+ ['$scope','$q','$routeParams','bucketSvc', 'egCore',
+ 'egConfirmDialog',
+function($scope, $q , $routeParams, bucketSvc, egCore,
+ egConfirmDialog) {
$scope.setTab('view');
$scope.bucketId = $routeParams.id;
return $q.all(promises).then(drawBucket);
}
+ $scope.deleteCopiesFromCatalog = function() {
+ egConfirmDialog.open(
+ egCore.strings.CONFIRM_DELETE_COPY_BUCKET_ITEMS_FROM_CATALOG,
+ '', {}
+ ).result.then(function() {
+ var fleshed_copies = [];
+ var promises = [];
+ angular.forEach(bucketSvc.currentBucket.items(), function(i) {
+ promises.push(
+ egCore.net.request(
+ 'open-ils.search',
+ 'open-ils.search.asset.copy.fleshed2.retrieve',
+ i.target_copy()
+ ).then(function(copy) {
+ copy.ischanged(1);
+ copy.isdeleted(1);
+ fleshed_copies.push(copy);
+ })
+ );
+ });
+ $q.all(promises).then(function() {
+ egCore.net.request(
+ 'open-ils.cat',
+ 'open-ils.cat.asset.copy.fleshed.batch.update',
+ egCore.auth.token(), fleshed_copies, true
+ ).then(function(resp) {
+ // TODO deal with events that this method could return
+ bucketSvc.bucketNeedsRefresh = true;
+ drawBucket();
+ });
+ });
+ });
+ }
+
// fetch the bucket; on error show the not-allowed message
if ($scope.bucketId)
drawBucket()['catch'](function() { $scope.forbidden = true });