From b9d642979da367f3df3c717fb531371da844cd08 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 13 May 2014 11:19:04 -0400 Subject: [PATCH] patron alert panel : inactive card retrieval Signed-off-by: Bill Erickson --- .../src/templates/staff/circ/patron/t_alerts.tt2 | 7 +-- .../web/js/ui/default/staff/circ/patron/app.js | 70 +++++++++++++++------- 2 files changed, 50 insertions(+), 27 deletions(-) diff --git a/Open-ILS/src/templates/staff/circ/patron/t_alerts.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_alerts.tt2 index 64996c1fb4..e9a0adf06b 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_alerts.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_alerts.tt2 @@ -23,10 +23,9 @@ [% l('Patron account is INACTIVE') %] - +
+ [% l('Patron account retrieved with an INACTIVE card.') %] +
diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js index 9c172ad71b..ed4f143889 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js @@ -36,10 +36,12 @@ angular.module('egPatronApp', ['ngRoute', 'ui.bootstrap', // 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() }]}; @@ -119,8 +121,8 @@ angular.module('egPatronApp', ['ngRoute', 'ui.bootstrap', * 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 @@ -151,6 +153,7 @@ function($q , $timeout , egCore, egUser) { service.alertsShown = false; service.patronExpired = false; service.patronExpiresSoon = false; + service.retrievedWithInactive = false; } service.resetPatronLists(); // initialize @@ -234,9 +237,11 @@ function($q , $timeout , egCore, egUser) { // 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 || @@ -248,6 +253,16 @@ function($q , $timeout , egCore, egUser) { 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 @@ -283,12 +298,28 @@ function($q , $timeout , egCore, egUser) { }]) /** - * 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 @@ -297,22 +328,12 @@ function($scope, $q, $location , $filter, egCore, egUser, patronSvc) { 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(); } @@ -329,7 +350,9 @@ function($scope , $location , egCore , egConfirmDialog , egUser , patronSvc) { // 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 @@ -773,6 +796,7 @@ function($scope, $routeParams , $location , egCore , patronSvc) { .then(function() { $scope.patronExpired = patronSvc.patronExpired; $scope.patronExpiresSoon = patronSvc.patronExpiresSoon; + $scope.retrievedWithInactive = patronSvc.retrievedWithInactive; }); }]) -- 2.11.0