LP#1635407 webstaff: show patron alert pane once
authorBill Erickson <berickxx@gmail.com>
Wed, 28 Dec 2016 21:15:24 +0000 (16:15 -0500)
committerKathy Lussier <klussier@masslnc.org>
Mon, 9 Jan 2017 15:59:00 +0000 (10:59 -0500)
Display the patron alerts pane only once per patron instance per
browser tab.  This is done by setting a new session storage value which
tracks the last alerted patron.  This value is replaced each time a new
patron is loaded into the main patron app (e.g. double-clicking the
patron row in patron search) and is maintained separately per browser
tab.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/web/js/ui/default/staff/circ/patron/app.js

index fcf195f..630ca9c 100644 (file)
@@ -248,13 +248,23 @@ function($q , $timeout , $location , egCore,  egUser , $locale) {
         service.patron_stats = null;
         service.noncat_ids = [];
         service.hasAlerts = false;
-        service.alertsShown = false;
         service.patronExpired = false;
         service.patronExpiresSoon = false;
         service.invalidAddresses = false;
     }
     service.resetPatronLists();  // initialize
 
+    // Returns true if the last alerted patron matches the current
+    // patron.  Otherwise, the last alerted patron is set to the 
+    // current patron and false is returned.
+    service.alertsShown = function() {
+        var key = 'eg.circ.last_alerted_patron';
+        var last_id = egCore.hatch.getSessionItem(key);
+        if (last_id && last_id == service.current.id()) return true;
+        egCore.hatch.setSessionItem(key, service.current.id());
+        return false;
+    }
+
     // shortcut to force-reload the current primary
     service.refreshPrimary = function() {
         if (!service.current) return $q.when();
@@ -584,8 +594,7 @@ function($scope,  $q,  $location , $filter,  egCore,  egUser,  patronSvc) {
         $scope.alert_penalties = 
             function() {return patronSvc.alert_penalties}
 
-        if (patronSvc.alertsShown) return false;
-        patronSvc.alertsShown = true;
+        if (patronSvc.alertsShown()) return false;
 
         // if the patron has any unshown alerts, show them now
         if (patronSvc.hasAlerts &&