From: Galen Charlton Date: Mon, 20 Jan 2020 17:12:53 +0000 (-0500) Subject: combobox: teach it how to start with a selected value when IDL-based X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b1dd2eca3ad7461e17b09ce0fb32474970da6736;p=working%2FEvergreen.git combobox: teach it how to start with a selected value when IDL-based Signed-off-by: Galen Charlton --- 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 3d9860471f..8c1d1e6d4e 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 @@ -68,6 +68,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 @@ -82,6 +83,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]; + }); + } } } } @@ -90,7 +101,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;