From: Bill Erickson Date: Tue, 27 Apr 2021 20:38:01 +0000 (-0400) Subject: LP1904036 Group display tree repairs / multiple parents X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ad209409686548afad49a852476a1bd79fb823a9;p=working%2FEvergreen.git LP1904036 Group display tree repairs / multiple parents Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/eg2/src/app/staff/share/patron/profile-select.component.ts b/Open-ILS/src/eg2/src/app/staff/share/patron/profile-select.component.ts index 399da34843..43ca28f033 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/patron/profile-select.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/patron/profile-select.component.ts @@ -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) {