handle an uncaught error on page load
authorJason Etheridge <jason@EquinoxOLI.org>
Wed, 2 Nov 2022 07:21:39 +0000 (03:21 -0400)
committerJason Etheridge <jason@EquinoxOLI.org>
Wed, 2 Nov 2022 07:21:39 +0000 (03:21 -0400)
Signed-off-by: Jason Etheridge <jason@EquinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/admin/local/stat_cat/stat_cat.component.ts

index 2bb894a..e19abea 100644 (file)
@@ -78,18 +78,20 @@ export class StatCatComponent implements OnInit {
     }
 
     setCurrentPerms() {
-        this.userPerms.canEditCopy =
-            this.userPerms.UPDATE_COPY_STAT_CAT.indexOf(this.selectedCopyOrgId) !== -1;
-        this.userPerms.canEditPatron =
-            this.userPerms.UPDATE_PATRON_STAT_CAT.indexOf(this.selectedPatronOrgId) !== -1;
-        this.userPerms.canCreateCopy =
-            this.userPerms.CREATE_COPY_STAT_CAT.indexOf(this.selectedCopyOrgId) !== -1;
-        this.userPerms.canCreatePatron =
-            this.userPerms.CREATE_PATRON_STAT_CAT.indexOf(this.selectedPatronOrgId) !== -1;
-        this.userPerms.canDeleteCopy =
-            this.userPerms.DELETE_COPY_STAT_CAT.indexOf(this.selectedCopyOrgId) !== -1;
-        this.userPerms.canDeletePatron =
-            this.userPerms.DELETE_PATRON_STAT_CAT.indexOf(this.selectedPatronOrgId) !== -1;
+        if (this.userPerms) {
+            this.userPerms.canEditCopy =
+                (this.userPerms.UPDATE_COPY_STAT_CAT || []).indexOf(this.selectedCopyOrgId) !== -1;
+            this.userPerms.canEditPatron =
+                (this.userPerms.UPDATE_PATRON_STAT_CAT || []).indexOf(this.selectedPatronOrgId) !== -1;
+            this.userPerms.canCreateCopy =
+                (this.userPerms.CREATE_COPY_STAT_CAT || []).indexOf(this.selectedCopyOrgId) !== -1;
+            this.userPerms.canCreatePatron =
+                (this.userPerms.CREATE_PATRON_STAT_CAT || []).indexOf(this.selectedPatronOrgId) !== -1;
+            this.userPerms.canDeleteCopy =
+                (this.userPerms.DELETE_COPY_STAT_CAT || []).indexOf(this.selectedCopyOrgId) !== -1;
+            this.userPerms.canDeletePatron =
+                (this.userPerms.DELETE_PATRON_STAT_CAT || []).indexOf(this.selectedPatronOrgId) !== -1;
+        }
     }
 
     onTabChange(event: any) {