From 78edd208f6bf061e803b65722321a4d2358049ae Mon Sep 17 00:00:00 2001
From: Mike Rylander <mrylander@gmail.com>
Date: Wed, 25 Apr 2018 12:32:15 -0400
Subject: [PATCH] LP#1753005: Avoid copy alert error for call numbers with no
 copies

When displaying the Holdings View tab for a bib in the web staff client,
if a volume record has no copies, a Javascript error gets thrown.

Item-less volumes still end up in svc.copies at this point, so at the
moment it is necessary to check whether copy_alerts actually exists.
Some renaming might also be in order to clarify that svc.copies doesn't
necessarily contain /only/ fleshed acp records.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
---
 Open-ILS/web/js/ui/default/staff/cat/services/holdings.js | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Open-ILS/web/js/ui/default/staff/cat/services/holdings.js b/Open-ILS/web/js/ui/default/staff/cat/services/holdings.js
index e6cc1457be..eb835f5a80 100644
--- a/Open-ILS/web/js/ui/default/staff/cat/services/holdings.js
+++ b/Open-ILS/web/js/ui/default/staff/cat/services/holdings.js
@@ -119,7 +119,8 @@ function(egCore , $q) {
 
                 // create virtual field for copy alert count
                 angular.forEach(svc.copies, function (cp) {
-                    cp.copy_alert_count = cp.copy_alerts.length;
+                    if (cp.copy_alerts) cp.copy_alert_count = cp.copy_alerts.length;
+                    else cp.copy_alert_count = 0;
                 });
 
                 // create a label using just the unique part of the owner list
-- 
2.11.0