}
service.resetPatronLists(); // initialize
+ // shortcut to force-reload the current primary
+ service.refreshPrimary = function() {
+ return service.setPrimary(null, service.current, true);
+ }
+
// sets the primary display user, fetching data as necessary.
service.setPrimary = function(id, user, force) {
var user_id = id ? id : (user ? user.id() : null);
console.debug('setting primary user to: ' + user_id);
- egCore.hatch.setLocalItem('eg.circ.last_patron', user_id);
+
+ if (!user_id) return $q.reject();
+
+ // when loading a new patron, update the last patron setting
+ if (!service.current || service.current.id() != user_id)
+ egCore.hatch.setLocalItem('eg.circ.last_patron', user_id);
// avoid running multiple retrievals for the same patron, which
// can happen during dbl-click by maintaining a single running
angular.module('egPatronApp').controller('PatronItemsOutCtrl',
- ['$scope','$q','$routeParams','egCore','egUser','patronSvc','egGridDataProvider','$modal',
-function($scope, $q, $routeParams, egCore , egUser, patronSvc , egGridDataProvider , $modal) {
+ ['$scope','$q','$routeParams','egCore','egUser','patronSvc',
+ 'egGridDataProvider','$modal','egCirc',
+function($scope, $q, $routeParams, egCore , egUser, patronSvc ,
+ egGridDataProvider , $modal , egCirc) {
$scope.initTab('items_out', $routeParams.id);
-
+
+ var display_lost, display_lo, display_cr;
+
+ // items out display settings
+ // NOTE:
+ egCore.org.settings([
+ 'ui.circ.items_out.lost',
+ 'ui.circ.items_out.longoverdue',
+ 'ui.circ.items_out.claimsreturned'])
+ .then(function(set) {
+ display_lost = Number(set['ui.circ.items_out.lost']) || 2;
+ display_lo = Number(set['ui.circ.items_out.longoverdue']) || 2;
+ display_cr = Number(set['ui.circ.items_out.claimsreturned']) || 2;
+ });
+
var provider = egGridDataProvider.instance({});
$scope.gridDataProvider = provider;
).then(function(outs) {
- patronSvc.items_out_ids = outs.out
- .concat(outs.overdue)
- .concat(outs.long_overdue)
- .concat(outs.lost)
- .concat(outs.claims_returned)
+ patronSvc.items_out_ids = outs.out.concat(outs.overdue);
+
+ // When rendering the items still checked out list, only
+ // show "alternate" circulations whose bitmask is 1
+ // (i.e. has a value of 1 or 5).
+
+ if (display_lo & 1) {
+ patronSvc.items_out_ids =
+ patronSvc.items_out_ids.concat(outs.long_overdue);
+ }
+
+ if (display_lost & 1) {
+ patronSvc.items_out_ids =
+ patronSvc.items_out_ids.concat(outs.lost);
+ }
+
+ if (display_cr & 1) {
+ patronSvc.items_out_ids =
+ patronSvc.items_out_ids.concat(outs.claims_returned);
+ }
// no item out
if (!patronSvc.items_out_ids.length) {
return;
}
- // relay the notified circs back to the grid through
- // our promise
- fetchCircs(offset, count).then(null, null, deferred.notify);
+ // relay the notified circs back to the grid through our promise
+ fetchCircs(offset, count).then(
+ deferred.resolve,
+ null,
+ deferred.notify
+ );
});
return deferred.promise;
});
}
+ $scope.mark_lost = function(items) {
+ if (!items.length) return;
+
+ var barcodes = items.map(function(circ) {
+ return circ.target_copy().barcode()
+ });
+
+ egCirc.mark_lost(barcodes)
+ .then(function() {
+ // reload the user to pick up changes in items out, fines, etc.
+ patronSvc.refreshPrimary();
+
+ // reload circs since LOST items may no longer be applicable
+ // for display.
+ patronSvc.items_out = [];
+ patronSvc.items_out_ids = [];
+ provider.refresh()
+ });
+ }
+
}]);
});
}
+ // Mark circulations as lost via copy barcode. As each item is
+ // processed, the returned promise is notified of the barcode.
+ // No confirmation dialog is presented.
+ service.mark_lost = function(copy_barcodes) {
+ var deferred = $q.defer();
+ var promises = [];
+
+ angular.forEach(copy_barcodes, function(barcode) {
+ promises.push(
+ egCore.net.request(
+ 'open-ils.circ',
+ 'open-ils.circ.circulation.set_lost',
+ egCore.auth.token(), {barcode : barcode}
+ ).then(function(resp) {
+ if (evt = egCore.evt.parse(resp)) {
+ console.error("Mark lost failed: " + evt.toString());
+ return;
+ }
+ // inform the caller as each item is processed
+ deferred.notify(barcode);
+ })
+ );
+ });
+
+ $q.all(promises).then(function() {deferred.resolve()});
+ return deferred.promise;
+ }
+
service.abort_transits = function(transit_ids) {
return egConfirmDialog.open(
egCore.strings.ABORT_TRANSIT_CONFIRM, '',
// avoid firing the collect if there is nothing to collect.
if (grid.selfManagedData && !grid.dataProvider.query) return;
- if (grid.collecting) return; // avoid parallel collects()
+ if (grid.collecting) return; // avoid parallel collect()
+ grid.collecting = true;
+
+ console.debug('egGrid.collect() offset='
+ + grid.offset + '; limit=' + grid.limit);
// ensure all of our dropdowns are closed
+ // TODO: git rid of these and just use dropdown-toggle,
+ // which is more reliable.
$scope.gridColumnPickerIsOpen = false;
$scope.gridRowCountIsOpen = false;
$scope.gridPageSelectIsOpen = false;
$scope.items = [];
$scope.selected = {};
- grid.collecting = true;
grid.dataProvider.get(grid.offset, grid.limit).then(
function() {
if (grid.controls.allItemsRetrieved)
if (grid.controls.itemRetrieved)
grid.controls.itemRetrieved(item);
}
- })['finally'](function() { grid.collecting = false })
+ }).finally(function() {
+ console.debug('egGrid.collect() complete');
+ grid.collecting = false
+ });
}
grid.init();