LP1790896: Receipt Errors with invalid emails user/jboyer/lp1790896_receipt_email
authorJason Boyer <jboyer@library.in.gov>
Thu, 7 Feb 2019 18:48:13 +0000 (13:48 -0500)
committerJason Boyer <jboyer@library.in.gov>
Thu, 7 Feb 2019 18:48:13 +0000 (13:48 -0500)
The attempt at belt-and-suspenders checking for a valid
email for use in the has_email template field sadly
causes the JS to trip over said suspenders if there is
a value in the field but it doesn't contain a '@'.

The raw return from "".match() (either an array or null)
is enough to do the right thing when converted into a
Boolean and doesn't cause the same problems.

Signed-off-by: Jason Boyer <jboyer@library.in.gov>
Open-ILS/web/js/ui/default/staff/circ/patron/bills.js
Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js
Open-ILS/web/js/ui/default/staff/circ/patron/items_out.js

index ceda5c8..9ec2e89 100644 (file)
@@ -450,7 +450,7 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
             card : { barcode : cusr.card().barcode() },
             expire_date : cusr.expire_date(),
             alias : cusr.alias(),
-            has_email : Boolean(patronSvc.current.email() && patronSvc.current.email().match(/.*@.*/).length),
+            has_email : Boolean(patronSvc.current.email() && patronSvc.current.email().match(/.*@.*/)),
             has_phone : Boolean(cusr.day_phone() || cusr.evening_phone() || cusr.other_phone())
         };
 
@@ -587,7 +587,7 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
                             card : { barcode : cusr.card().barcode() },
                             expire_date : cusr.expire_date(),
                             alias : cusr.alias(),
-                            has_email : Boolean(cusr.email() && cusr.email().match(/.*@.*/).length),
+                            has_email : Boolean(cusr.email() && cusr.email().match(/.*@.*/)),
                             has_phone : Boolean(cusr.day_phone() || cusr.evening_phone() || cusr.other_phone())
                         }
                     }
@@ -1086,7 +1086,7 @@ function($scope,  $q , egCore , patronSvc , billSvc , egPromptDialog , $location
                             card : { barcode : cusr.card().barcode() },
                             expire_date : cusr.expire_date(),
                             alias : cusr.alias(),
-                            has_email : Boolean(cusr.email() && cusr.email().match(/.*@.*/).length),
+                            has_email : Boolean(cusr.email() && cusr.email().match(/.*@.*/)),
                             has_phone : Boolean(cusr.day_phone() || cusr.evening_phone() || cusr.other_phone())
                         }
                     }
index 1cbb05e..ba7c545 100644 (file)
@@ -96,7 +96,7 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc ,
         return (
             patronSvc.current &&
             patronSvc.current.email() &&
-            patronSvc.current.email().match(/.*@.*/).length
+            patronSvc.current.email().match(/.*@.*/)
         );
     }
 
index 110ead8..92184a1 100644 (file)
@@ -383,7 +383,7 @@ function($scope , $q , $routeParams , $timeout , egCore , egUser , patronSvc ,
             money_summary : patronSvc.patron_stats.fines,
             expire_date : cusr.expire_date(),
             alias : cusr.alias(),
-            has_email : Boolean(patronSvc.current.email() && patronSvc.current.email().match(/.*@.*/).length),
+            has_email : Boolean(patronSvc.current.email() && patronSvc.current.email().match(/.*@.*/)),
             has_phone : Boolean(cusr.day_phone() || cusr.evening_phone() || cusr.other_phone())
         };