function fetch_circs(id_list, offset, count) {
if (!id_list.length || id_list.length < offset + 1) return $q.when();
-
- var deferred = $q.defer();
var rendered = 0;
// fetch the lot of circs and stream the results back via notify
- egCore.pcrud.search('circ', {id : id_list},
+ return egCore.pcrud.search('circ', {id : id_list},
{ flesh : 4,
flesh_fields : {
circ : ['target_copy', 'workstation', 'checkin_workstation'],
// we need an order-by to support paging
order_by : {circ : ['xact_start']}
- }).then(deferred.resolve, null, function(circ) {
+ }).then(null, null, function(circ) {
circ.circ_lib(egCore.org.get(circ.circ_lib())); // local fleshing
// Translate bib display field JSON blobs to JS.
return part.label()
}).join(',');
- // call open-ils to get overdue notice count and Last notice date
-
+ // call open-ils to get overdue notice count and Last notice date
+
+
egCore.net.request(
'open-ils.actor',
'open-ils.actor.user.itemsout.notices',
if (notice.numNotices){
circ.action_trigger_event_count = notice.numNotices;
circ.action_trigger_latest_event_date = notice.lastDt;
- }
- patronSvc.items_out.push(circ);
+ }
});
- if (rendered++ >= offset && rendered <= count){ deferred.notify(circ) };
- });
+ if (rendered++ >= offset && rendered <= count) {
+ patronSvc.items_out.push(circ);
+ }
- return deferred.promise;
+ }).then(function() {
+ // Wrap up with the notifier which performs our client-side sorting
+ return provider.arrayNotifier(patronSvc.items_out, offset, count);
+ });
}
function fetch_noncat_circs(id_list, offset, count) {
// notify()'s from egCore.net.request don't leak into the
// final set of notifies (i.e. the real responses);
- var deferred = $q.defer();
- get_circ_ids().then(function() {
+ return get_circ_ids().then(function() {
id_list = $scope[$scope.items_out_display + '_list'];
$scope.gridDataProvider.grid.totalCount = id_list.length;
// relay the notified circs back to the grid through our promise
- fetch_circs(id_list, offset, count).then(
- deferred.resolve, null, deferred.notify);
+
+ return fetch_circs(id_list, offset, count);
});
-
- return deferred.promise;
}