From: Galen Charlton Date: Mon, 20 Jan 2020 17:12:53 +0000 (-0500) Subject: LP#1850547: eg-combobox: handle startId if idlClass is set X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=61cb3ab5feeb9c19b928731144505f7d242ff8ad;p=evergreen%2Ftadl.git LP#1850547: eg-combobox: handle startId if idlClass is set This patch teaches the Angular eg-combobox component to retrieve the record indicated by the startId attribute when an IDL class is specified. Sponsored-by: Evergreen Community Development Initiative Sponsored-by: Georgia Public Library Service Sponsored-by: Indiana State Library Sponsored-by: C/W MARS Signed-off-by: Galen Charlton Signed-off-by: Tiffany Little Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts b/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts index 2afbe4105c..56da7479e0 100644 --- a/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts +++ b/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts @@ -71,6 +71,7 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit { // onChange() is NOT fired when applying the default value, // unless startIdFiresOnChange is set to true. @Input() startId: any = null; + @Input() idlClass: string; @Input() startIdFiresOnChange: boolean; // Allow the selected entry ID to be passed via the template @@ -89,6 +90,16 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit { // It's possible the selected ID lives in a set of entries // that are yet to be provided. this.startId = id; + if (this.idlClass) { + this.pcrud.retrieve(this.idlClass, id) + .subscribe(rec => { + this.entrylist = [{ + id: id, + label: rec[this.idlField]() + }]; + this.selected = this.entrylist.filter(e => e.id === id)[0]; + }); + } } } @@ -96,7 +107,6 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit { return this.selected ? this.selected.id : null; } - @Input() idlClass: string; @Input() idlField: string; @Input() idlIncludeLibraryInLabel: string; @Input() asyncDataSource: (term: string) => Observable;