Created
July 2, 2021 17:11
-
-
Save berick/56fd9565f1167b82afcf2b75eeb842b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.addToBucket = function(recs) { | |
if (recs.length == 0) return; | |
bucketSvc.bucketNeedsRefresh = true; | |
var promise = $q.when(); | |
angular.forEach(recs, | |
function(rec) { | |
var item = new egCore.idl.ccbi(); | |
item.bucket(bucketSvc.currentBucket.id()); | |
item.target_copy(rec.id); | |
promise = promise.then(function() { | |
console.log('sending request'); | |
return egCore.net.request( | |
'open-ils.actor', | |
'open-ils.actor.container.item.create', | |
egCore.auth.token(), 'copy', item | |
).then(function(resp) { | |
console.log('receiving response') | |
// HACK: add the IDs of the added items so that the size | |
// of the view list will grow (and update any UI looking at | |
// the list size). The data stored is inconsistent, but since | |
// we are forcing a bucket refresh on the next rendering of | |
// the view pane, the list will be repaired. | |
bucketSvc.currentBucket.items().push(resp); | |
}); | |
}); | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment