Proper lookup of user setting values
authorMike Rylander <mrylander@gmail.com>
Thu, 4 Aug 2016 13:39:45 +0000 (09:39 -0400)
committerMike Rylander <mrylander@gmail.com>
Thu, 4 Aug 2016 13:39:45 +0000 (09:39 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js

index d336d70..04110aa 100644 (file)
@@ -34,12 +34,21 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc ,
         );
     }
 
+    function setting_value (user, setting) {
+        if (user) {
+            var list = user.settings().filter(function(s){
+                return s.name() == setting;
+            });
+
+            if (list.length) return list[0].value();
+        }
+    }
+
     $scope.email_receipt = function() {
-        return  (
-            patronSvc.current &&
-            patronSvc.current.settings()['circ.send_email_checkout_receipts'] &&
-            patronSvc.current.settings()['circ.send_email_checkout_receipts'] == 'true'
-        );
+        return setting_value(
+            patronSvc.current,
+            'circ.send_email_checkout_receipts'
+        ) == 'true';
     }
 
     $scope.using_hatch = egCore.hatch.usingHatch();