LP1904036 Group display tree repairs / multiple parents
authorBill Erickson <berickxx@gmail.com>
Tue, 27 Apr 2021 20:38:01 +0000 (16:38 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:33 +0000 (20:13 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>

Open-ILS/src/eg2/src/app/staff/share/patron/profile-select.component.ts

index 399da34..43ca28f 100644 (file)
@@ -154,7 +154,20 @@ export class ProfileSelectComponent implements ControlValueAccessor, OnInit {
         return PAD_SPACE.repeat(depth) + grp.name();
     }
 
-    sortGroups(groups: IdlObject[], grp?: IdlObject) {
+    sortGroups(groups: IdlObject[]) {
+
+        // When using display entries, there can be multiple groups
+        // with no parent.
+
+        groups.forEach(grp => {
+            if (grp.parent() === null) {
+                this.sortOneGroup(groups, grp);
+            }
+        });
+    }
+
+    sortOneGroup(groups: IdlObject[], grp: IdlObject) {
+
         if (!grp) {
             grp = groups.filter(g => g.parent() === null)[0];
         }
@@ -172,7 +185,7 @@ export class ProfileSelectComponent implements ControlValueAccessor, OnInit {
                     return a.name() < b.name() ? -1 : 1;
                 }
             })
-            .forEach(child => this.sortGroups(groups, child));
+            .forEach(child => this.sortOneGroup(groups, child));
     }
 
     writeValue(pgt: IdlObject) {