LP#1402797 Add invalid-address alert
authorMike Rylander <mrylander@gmail.com>
Thu, 30 Oct 2014 15:06:14 +0000 (11:06 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 12 Feb 2015 16:58:27 +0000 (11:58 -0500)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/templates/staff/circ/patron/t_alerts.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/app.js

index 822240c..9281362 100644 (file)
     [% l('Patron account retrieved with an INACTIVE card.') %]
   </div>
 
+  <div class="alert alert-warning" ng-if="invalidAddresses">
+    [% l('Patron account has invalid addresses.') %]
+  </div>
+
   <!-- alert message -->
   <div class="row" ng-if="patron().alert_message()">
     <div class="col-md-12">
index c607e29..bd7cb8a 100644 (file)
@@ -239,6 +239,7 @@ function($q , $timeout , $location , egCore,  egUser , $locale) {
         service.patronExpired = false;
         service.patronExpiresSoon = false;
         service.retrievedWithInactive = false;
+        service.invalidAddresses = false;
     }
     service.resetPatronLists();  // initialize
 
@@ -383,6 +384,22 @@ function($q , $timeout , $location , egCore,  egUser , $locale) {
         return $q.when(false);
     }
 
+    // resolves to true if the patron account has any invalid addresses.
+    service.testInvalidAddrs = function() {
+
+        if (service.invalidAddresses)
+            return $q.when(true);
+
+        var fail = false;
+
+        angular.forEach(
+            service.current.addresses(), 
+            function(addr) { if (!addr.valid()) fail = true }
+        );
+
+        return $q.when(fail);
+    }
+
     // resolves to true if there is any aspect of the patron account
     // which should produce a message in the alerts panel
     service.checkAlerts = function() {
@@ -420,6 +437,11 @@ function($q , $timeout , $location , egCore,  egUser , $locale) {
             deferred.resolve(service.hasAlerts);
         });
 
+        service.testInvalidAddrs().then(function(bool) {
+            if (bool) service.invalidAddresses = true;
+            deferred.resolve(service.invalidAddresses);
+        });
+
         return deferred.promise;
     }
 
@@ -1184,6 +1206,7 @@ function($scope,  $routeParams , $location , egCore , patronSvc) {
         $scope.patronExpired = patronSvc.patronExpired;
         $scope.patronExpiresSoon = patronSvc.patronExpiresSoon;
         $scope.retrievedWithInactive = patronSvc.retrievedWithInactive;
+        $scope.invalidAddresses = patronSvc.invalidAddresses;
     });
 
 }])