.controller('PendingRequestsCtrl',
['$scope','$q','$route','egNet','egAuth','egPCRUD','egOrg','orgSelector',
function ($scope, $q, $route, egNet, egAuth, egPCRUD, egOrg, orgSelector) {
- var self = this;
-
- this.displayOne = function(display, hold_blob) {
- var hold = display.hold = hold_blob.hold;
- display.request_time = hold.hold_request_time = hold.request_time();
- display.expire_time = hold.expire_time();
- display.patron_card = hold_blob.patron_barcode;
- display.patron_name = display.hold_request_usr =
- (hold_blob.patron_first || '') +
- ' ' + (hold_blob.patron_last || '');
- display.request_lib = display.hold_request_lib =
- egOrg.get(hold.request_lib()).shortname();
- display.hold_pickup_lib =
- egOrg.get(hold.pickup_lib()).shortname();
- display.title = hold_blob.mvr.title(); // MVR BOO
- display.author = hold_blob.mvr.author(); // MVR BOO
- if (hold_blob.copy) {
- display.copy = hold_blob.copy;
- display.current_copy = hold_blob.copy.barcode();
- display.current_copy_lib =
- egOrg.get(hold_blob.copy.source_lib()).shortname();
- display.current_copy_enc = encodeURIComponent(hold_blob.copy.barcode());
- display.barcode = display.copy.barcode();
- display.status = display.copy.status();
- display.item_circ_lib = egOrg.get(display.copy.circ_lib()).shortname();
- }
- if (hold_blob.volume) {
- display.call_number = hold_blob.volume.label();
- }
- if ($scope.orientation_lender)
- display.next_action = 'ill-home-capture';
- };
+
+ $scope.itemList.sort = 'request_time';
$scope.drawTable = function() {
$scope.itemList.items = [];
}
}
- egPCRUD.search('ahr', query,
- { limit : $scope.itemList.limit,
- offset : $scope.itemList.offset,
- order_by : {'ahr' : 'request_time, id'}
- },
- {atomic : true}
+ // circ_lib and request_lib are retrieved as IDs since
+ // our query blob assumes they are IDs
+ var fields = {
+ id : {path : 'id'},
+ request_time : {path : 'request_time'},
+ expire_time : {path : 'expire_time'},
+ patron_barcode : {path : 'usr.card.barcode'},
+ patron_given_name : {path : 'usr.first_given_name'},
+ patron_family_name : {path : 'usr.family_name'},
+ request_lib : {path : 'request_lib'},
+ pickup_lib : {path : 'pickup_lib.shortname'},
+ title : {path : 'bib_rec.bib_record.simple_record.title'},
+ author : {path : 'bib_rec.bib_record.simple_record.author'},
+ copy_barcode : {path : 'current_copy.barcode'},
+ circ_lib : {path : 'current_copy.circ_lib'},
+ call_number : {path : 'current_copy.call_number.label'}
+ };
+ angular.forEach(fields, function(f) { f.display = true });
- ).then(function(holds) {
+ egNet.request(
+ 'open-ils.fielder',
+ 'open-ils.fielder.flattened_search',
+ egAuth.token(), "ahr", fields,
+ query,
+ { sort : [$scope.itemList.sort],
+ limit : $scope.itemList.limit,
+ offset : $scope.itemList.offset
+ }
+ ).then(
+ null, // success
+ null, // error
+ function(hold) { // notify handler
+ hold.index = $scope.itemList.count();
+
+ hold.request_lib = egOrg.get(hold.request_lib).shortname();
+ if (hold.circ_lib) {
+ hold.circ_lib = egOrg.get(hold.circ_lib).shortname();
+ hold.copy_barcode_enc = encodeURIComponent(hold.copy_barcode);
+ }
+
+ if ($scope.orientation_lender)
+ hold.next_action = 'ill-home-capture';
- // fetch the extended hold details for each hold
- // to pick up the title, etc.
- angular.forEach(holds, function(hold) {
- var display = {
- id : hold.id(),
- index : $scope.itemList.count()
- };
// we don't use itemList.addItem(),
- // since it fetches data differently
- $scope.itemList.items.push(display);
- egNet.request(
- 'open-ils.circ',
- 'open-ils.circ.hold.details.retrieve',
- egAuth.token(), hold.id()
- ).then(function(hold_blob) {
- self.displayOne(display, hold_blob);
- });
- });
- });
- };
+ // since we're managing our own data fetching
+ $scope.itemList.items.push(hold);
+ }
+ );
+ }
$scope.firstPage = function() {
};
$scope.nextPage = function() {
- $scope.itemList.offset += $scope.itemList.limit;
+ $scope.itemList.incrementPage();
$scope.drawTable();
};
$scope.prevPage = function() {
- $scope.itemList.offset -= $scope.itemList.limit;
+ $scope.itemList.decrementPage();
$scope.drawTable();
};