From 7b7afd602047ec7c1e52acf9ae6f0260f8842ded Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 5 Jul 2019 11:18:59 -0400 Subject: [PATCH] LP1830432 Uniqify reported org IDs / sandbox tweaks Err on the side of caution and ensure the org family selector always reports a unique list of org unit IDs. Sandbox language tweaks. Signed-off-by: Bill Erickson --- .../org-family-select/org-family-select.component.ts | 8 ++++++-- .../src/eg2/src/app/staff/sandbox/sandbox.component.html | 6 +++--- .../src/eg2/src/app/staff/sandbox/sandbox.component.ts | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/share/org-family-select/org-family-select.component.ts b/Open-ILS/src/eg2/src/app/share/org-family-select/org-family-select.component.ts index 6fd1790c98..3e1e6e8e34 100644 --- a/Open-ILS/src/eg2/src/app/share/org-family-select/org-family-select.component.ts +++ b/Open-ILS/src/eg2/src/app/share/org-family-select/org-family-select.component.ts @@ -110,14 +110,18 @@ export class OrgFamilySelectComponent implements ControlValueAccessor, OnInit { } if (this.includeDescendants.value) { - // can result in duplicate workstation org IDs... meh this.options.orgIds = this.options.orgIds.concat( this.org.descendants(this.options.primaryOrgId, true)); } + // Using ancestors() and descendants() can result in + // duplicate org ID's. Be nice and uniqify. + const hash: any = {}; + this.options.orgIds.forEach(id => hash[id] = true); + this.options.orgIds = Object.keys(hash).map(id => Number(id)); + this.propagateChange(this.options); }; - } writeValue(value: OrgFamily) { diff --git a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html index fa58e905e0..38908aeed6 100644 --- a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html +++ b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html @@ -200,11 +200,11 @@
+ labelText="Choose the fanciest libraries"> -
+
error - Too many bad libraries! + Too many fancy libraries!
diff --git a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts index 17c6e6deee..52931a04e4 100644 --- a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts @@ -94,7 +94,7 @@ export class SandboxComponent implements OnInit { {'id': 4, 'includeAncestors': false, 'includeDescendants': true}, (c: FormControl) => { // An Angular custom validator if (c.value.orgIds && c.value.orgIds.length > 5) { - return { tooMany: 'That\'s too many bad libraries!' }; + return { tooMany: 'That\'s too many fancy libraries!' }; } else { return null; } @@ -102,7 +102,7 @@ export class SandboxComponent implements OnInit { }); this.badOrgForm.get('badOrgSelector').valueChanges.subscribe(bad => { - this.toast.danger('The worst libraries are: ' + JSON.stringify(bad.orgIds)); + this.toast.danger('The fanciest libraries are: ' + JSON.stringify(bad.orgIds)); }); this.gridDataSource.data = [ -- 2.43.2