}])
-
.controller('CatalogCtrl',
['$scope','$routeParams','$location','$window','$q','egCore','egHolds','egCirc','egConfirmDialog','ngToast',
- 'egGridDataProvider','egHoldGridActions','$timeout','$uibModal','holdingsSvc','egUser','conjoinedSvc',
+ 'egGridDataProvider','egHoldGridActions','egProgressModal','$timeout','$uibModal','holdingsSvc','egUser','conjoinedSvc',
'$cookies',
function($scope , $routeParams , $location , $window , $q , egCore , egHolds , egCirc , egConfirmDialog , ngToast ,
- egGridDataProvider , egHoldGridActions , $timeout , $uibModal , holdingsSvc , egUser , conjoinedSvc,
+ egGridDataProvider , egHoldGridActions ,egProgressModal, $timeout , $uibModal , holdingsSvc , egUser , conjoinedSvc,
$cookies
) {
var hold_ids = []; // current list of holds
function fetchHolds(offset, count) {
var ids = hold_ids.slice(offset, offset + count);
+
return egHolds.fetch_holds(ids).then(null, null,
function(hold_data) {
return hold_data;
if ($scope.record_tab != 'holds') return $q.when();
var deferred = $q.defer();
hold_ids = []; // no caching ATM
-
// fetch the IDs
egCore.net.request(
'open-ils.circ',
{pickup_lib : egCore.org.descendants($scope.pickup_ou.id(), true)}
).then(
function(hold_data) {
+ if(hold_data.title_holds.length){
+ egProgressModal.open().result;};
angular.forEach(hold_data, function(list, type) {
hold_ids = hold_ids.concat(list);
});
fetchHolds(offset, count).then(
- deferred.resolve, null, deferred.notify);
+ deferred.resolve, null, deferred.notify).then(function(){
+ egProgressModal.close();
+ });
}
);
$scope.detail_hold_record_id = $scope.record_id;
// refresh the holds grid
provider.refresh();
+
break;
}
}
/**
+ * egProgressModal.open();
+ */
+.factory('egProgressModal',
+
+ ['$uibModal','$interpolate',
+function($uibModal, $interpolate){
+ var service = {};
+
+ service.open = function() {
+ return $uibModal.open({
+ templateUrl: './share/t_progress_bar',
+ controller: ['$scope', '$uibModalInstance',
+ function($scope, $uibModalInstance) {
+ service.currentInstance = $uibModalInstance;
+ }
+ ]
+ });
+ };
+ service.close = function() {
+ if (service.currentInstance) {
+ service.currentInstance.close();
+ delete service.currentInstance;
+ }
+ }
+ return service;
+}])
+
+/**
* egAlertDialog.open({message : 'hello {{name}}'}).result.then(
* function() { console.log('alert closed') });
*/