</div>
<div class="modal-body">
<div class="row">
- <div class="form-inline">
- <div class="form-gruop">
- <label for="select-bucket">[% l('Copy this record into which bucket?') %]</label>
- <select id="select-bucket" class="form-control" ng-model="bucket_id"
- ng-options="bucket.name() for bucket in allBuckets track by bucket.id()">
- </select>
- <button class="btn btn-primary" ng-class="{disabled : !bucket_id}"
- ng-click="add_to_bucket()">[% l('Add To Selected Bucket') %]</button>
- </div>
+ <div class="col-md-4">
+ <label for="select-bucket">[% l('Name of existing bucket') %]</label>
+ </div>
+ <div class="col-md-4">
+ <select id="select-bucket" class="form-control" ng-model="bucket_id"
+ ng-options="bucket.id() as bucket.name() for bucket in allBuckets | orderBy:bucket.name()">
+ </select>
+ </div>
+ <div class="col-md-4">
+ <button class="btn btn-primary" ng-class="{disabled : !bucket_id}"
+ ng-click="add_to_bucket()">[% l('Add To Selected Bucket') %]</button>
</div>
</div>
- <div class="row">
- <div class="form-inline">
- <div class="form-gruop">
- <label for="new-bucket-name">[% l('Name For New Bucket') %]</label>
+ <div class="row pad-vert">
+ <div class="col-md-4">
+ <label for="new-bucket-name">[% l('Name For New Bucket') %]</label>
+ </div>
+ <div class="col-md-4">
<input type="text" class="form-control" id="new-bucket-name" ng-model="newBucketName" />
- <button class="btn btn-primary" ng-class="{disabled : !newBucketName}"
- ng-click="add_to_new_bucket()">[% l('Add To New Bucket') %]</button>
+ </div>
+ <div class="col-md-4">
+ <button class="btn btn-primary" ng-class="{disabled : !newBucketName}"
+ ng-click="add_to_new_bucket()">[% l('Add To New Bucket') %]</button>
</div>
</div>
</div>
}
});
+ $scope.add_copies_to_bucket = function() {
+ var copy_list = gatherSelectedHoldingsIds();
+ if (copy_list.length == 0) return;
+
+ return $modal.open({
+ templateUrl: './cat/catalog/t_add_to_bucket',
+ animation: true,
+ size: 'md',
+ controller:
+ ['$scope','$modalInstance',
+ function($scope , $modalInstance) {
+
+ $scope.bucket_id = 0;
+ $scope.newBucketName = '';
+ $scope.allBuckets = [];
+
+ egCore.net.request(
+ 'open-ils.actor',
+ 'open-ils.actor.container.retrieve_by_class.authoritative',
+ egCore.auth.token(), egCore.auth.user().id(),
+ 'copy', 'staff_client'
+ ).then(function(buckets) { $scope.allBuckets = buckets; });
+
+ $scope.add_to_bucket = function() {
+ var promises = [];
+ angular.forEach(copy_list, function (cp) {
+ var item = new egCore.idl.ccbi()
+ item.bucket($scope.bucket_id);
+ item.target_copy(cp);
+ promises.push(
+ egCore.net.request(
+ 'open-ils.actor',
+ 'open-ils.actor.container.item.create',
+ egCore.auth.token(), 'copy', item
+ )
+ );
+
+ return $q.all(promises).then(function() {
+ $modalInstance.close();
+ });
+ });
+ }
+
+ $scope.add_to_new_bucket = function() {
+ var bucket = new egCore.idl.ccb();
+ bucket.owner(egCore.auth.user().id());
+ bucket.name($scope.newBucketName);
+ bucket.description('');
+ bucket.btype('staff_client');
+
+ return egCore.net.request(
+ 'open-ils.actor',
+ 'open-ils.actor.container.create',
+ egCore.auth.token(), 'copy', bucket
+ ).then(function(bucket) {
+ $scope.bucket_id = bucket;
+ $scope.add_to_bucket();
+ });
+ }
+
+ $scope.cancel = function() {
+ $modalInstance.dismiss();
+ }
+ }]
+ });
+ }
+
$scope.requestItems = function() {
var copy_list = gatherSelectedHoldingsIds();
if (copy_list.length == 0) return;