From e85fb2909381632ab114f0d923aeda5089e37467 Mon Sep 17 00:00:00 2001 From: Galen Charlton <gmc@equinoxinitiative.org> Date: Tue, 4 Jun 2019 10:01:27 -0400 Subject: [PATCH] LP#1831783: improvements to the Angular org-select widget - add reset() method - add method for retrieve current selected OU. This can be invoked from local template references in parent templates like this: <button ... (click)="doAction(ousel.selectedOrg())" ... ... <eg-org-select (onChange)="doAction($event)" #ousel></eg-org-select> Sponsored-by: MassLNC Sponsored-by: Georgia Public Library Service Sponsored-by: Indiana State Library Sponsored-by: CW MARS Sponsored-by: King County Library System Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org> Signed-off-by: Bill Erickson <berickxx@gmail.com> --- .../eg2/src/app/share/org-select/org-select.component.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts b/Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts index f455c36bf3..dee3248939 100644 --- a/Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts +++ b/Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts @@ -100,6 +100,16 @@ export class OrgSelectComponent implements OnInit { // Does not fire on initialOrg @Output() onChange = new EventEmitter<IdlObject>(); + // convenience method to get an IdlObject representing the current + // selected org unit. One way of invoking this is via a template + // reference variable. + selectedOrg(): IdlObject { + if (this.selected == null) { + return null; + } + return this.org.get(this.selected.id); + } + constructor( private auth: AuthService, private store: StoreService, @@ -174,6 +184,11 @@ export class OrgSelectComponent implements OnInit { // Remove the tree-padding spaces when matching. formatter = (result: OrgDisplay) => result.label.trim(); + // reset the state of the component + reset() { + this.selected = null; + } + filter = (text$: Observable<string>): Observable<OrgDisplay[]> => { return text$.pipe( debounceTime(200), -- 2.11.0