From: Galen Charlton <gmc@equinoxinitiative.org> Date: Tue, 4 Jun 2019 14:01:27 +0000 (-0400) Subject: LP#1831783: improvements to the Angular org-select widget X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e85fb2909381632ab114f0d923aeda5089e37467;p=contrib%2FConifer.git 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> --- 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),