From 72209baefab1133c4fe6776ac4b60f79027ad49d Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 4 Nov 2013 16:32:30 -0500 Subject: [PATCH] ff ui : fetch pending holds via flattener Signed-off-by: Bill Erickson --- .../src/templates/staff/fulfillment/t_pending.tt2 | 12 ++- .../web/js/ui/default/staff/fulfillment/app.js | 110 ++++++++++----------- 2 files changed, 57 insertions(+), 65 deletions(-) diff --git a/Open-ILS/src/templates/staff/fulfillment/t_pending.tt2 b/Open-ILS/src/templates/staff/fulfillment/t_pending.tt2 index 535a52f683..22f1b24f40 100644 --- a/Open-ILS/src/templates/staff/fulfillment/t_pending.tt2 +++ b/Open-ILS/src/templates/staff/fulfillment/t_pending.tt2 @@ -37,6 +37,7 @@ [% l('Patron Name') %] [% l('Patron Barcode') %] [% l('Requesting Library') %] + [% l('Pickup Library') %] [% l('Targeted Copy') %] [% l('Copy Library') %] [% l('Title') %] @@ -48,15 +49,16 @@ {{item.id}} {{item.request_time | date}} {{item.expire_time | date}} - {{item.patron_name}} - {{item.patron_card}} + {{item.patron_given_name}} {{item.patron_family_name}} + {{item.patron_barcode}} {{item.request_lib}} + {{item.pickup_lib}} - {{item.current_copy}} + href="./fulfillment/status/{{item.copy_barcode_enc}}"> + {{item.copy_barcode}} - {{item.current_copy_lib}} + {{item.circ_lib}} {{item.title}} diff --git a/Open-ILS/web/js/ui/default/staff/fulfillment/app.js b/Open-ILS/web/js/ui/default/staff/fulfillment/app.js index 3358169135..fed493fc67 100644 --- a/Open-ILS/web/js/ui/default/staff/fulfillment/app.js +++ b/Open-ILS/web/js/ui/default/staff/fulfillment/app.js @@ -721,38 +721,8 @@ function ($scope, $q, $route, $location, egPCRUD, orgSelector) { .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 = []; @@ -785,35 +755,55 @@ function ($scope, $q, $route, egNet, egAuth, egPCRUD, egOrg, orgSelector) } } - 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() { @@ -822,12 +812,12 @@ function ($scope, $q, $route, egNet, egAuth, egPCRUD, egOrg, orgSelector) }; $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(); }; -- 2.11.0