// app-globally modify the default flesh fields for
// fleshed user retrieval
- egUser.defaultFleshFields.push('profile');
- egUser.defaultFleshFields.push('net_access_level');
- egUser.defaultFleshFields.push('ident_type');
- egUser.defaultFleshFields.push('ident_type2');
+ egUser.defaultFleshFields = egUser.defaultFleshFields.concat([
+ 'net_access_level',
+ 'ident_type',
+ 'ident_type2',
+ 'cards'
+ ]);
return egCore.startup.go()
}]};
* Patron service
*/
.factory('patronSvc',
- ['$q','$timeout','egCore','egUser',
-function($q , $timeout , egCore, egUser) {
+ ['$q','$timeout','$location','egCore','egUser',
+function($q , $timeout , $location , egCore, egUser) {
var service = {
// cached patron search results
service.alertsShown = false;
service.patronExpired = false;
service.patronExpiresSoon = false;
+ service.retrievedWithInactive = false;
}
service.resetPatronLists(); // initialize
// resolves to true if there is any aspect of the patron account
// which should produce a message in the alerts panel
service.checkAlerts = function() {
- var deferred = $q.defer();
- if (service.hasAlerts) return $q.when(true);
+ if (service.hasAlerts) // already checked
+ return $q.when(true);
+
+ var deferred = $q.defer();
var p = service.current;
if (p.standing_penalties().length ||
service.hasAlerts = true;
}
+ // see if the user was retrieved with an inactive card
+ if (bc = $location.search().card) {
+ var card = p.cards().filter(
+ function(c) { return c.barcode() == bc })[0];
+
+ if (card && card.active() == 'f') {
+ service.hasAlerts = true;
+ service.retrievedWithInactive = true;
+ }
+ }
// regardless of whether we know of alerts, we still need
// to test/fetch the expire data for display
}])
/**
- * Manages tabbed patron view
+ * Manages tabbed patron view.
+ * This is the parent scope of all patron tab scopes.
+ *
* */
.controller('PatronCtrl',
['$scope','$q','$location','$filter','egCore','egUser','patronSvc',
function($scope, $q, $location , $filter, egCore, egUser, patronSvc) {
+ function redirectToAlertPanel() {
+ if (patronSvc.alertsShown) return;
+ patronSvc.alertsShown = true;
+
+ // if the patron has any unshown alerts, show them now
+ if (patronSvc.hasAlerts &&
+ !$location.path().match(/alerts$/)) {
+
+ $location
+ .path('/circ/patron/' + patronSvc.current.id() + '/alerts')
+ .search('card', null);
+ }
+ }
+
// called after each route-specified controller is instantiated.
// this doubles as a way to inform the top-level controller that
// egStartup.go() has completed, which means we are clear to
console.log('init tab ' + tab);
$scope.tab = tab;
$scope.aous = egCore.env.aous;
+
if (patron_id) {
- $scope.patron_id = patron_id
+ $scope.patron_id = patron_id;
return patronSvc.setDefault($scope.patron_id)
.then(function() {return patronSvc.checkAlerts()})
- .then(function() {
- console.log("patron has alerts = " + patronSvc.hasAlerts);
-
- // if the patron has any unshown alerts, show them now
- if (!patronSvc.alertsShown &&
- patronSvc.hasAlerts &&
- !$location.path().match(/\/alerts$/)) {
- patronSvc.alertsShown = true;
- $location.path('/circ/patron/'
- + patronSvc.current.id() + '/alerts');
- }
- });
+ .then(redirectToAlertPanel);
}
return $q.when();
}
// jump to the patron checkout UI
function loadPatron(user_id) {
- $location.path('/circ/patron/' + user_id + '/checkout');
+ $location
+ .path('/circ/patron/' + user_id + '/checkout')
+ .search('card', $scope.args.barcode);
}
// create an opt-in=yes response for the loaded user
.then(function() {
$scope.patronExpired = patronSvc.patronExpired;
$scope.patronExpiresSoon = patronSvc.patronExpiresSoon;
+ $scope.retrievedWithInactive = patronSvc.retrievedWithInactive;
});
}])