From ce06bea197ac69ae5c800171c47323cb9185c4a3 Mon Sep 17 00:00:00 2001 From: Galen Charlton <gmc@equinoxinitiative.org> Date: Sun, 16 Jun 2019 20:30:10 -0400 Subject: [PATCH] LP#1832897: Angular combobox: add idlIncludeLibraryInLabel option The new attribute, idlIncludeLibraryInLabel, specifies the column containing a linked OU. That OU's shortname will then be included in the label. This attribute takes effect only if idlClass is specified. Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org> Signed-off-by: Bill Erickson <berickxx@gmail.com> Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu> --- .../eg2/src/app/share/combobox/combobox.component.ts | 20 +++++++++++++++++--- .../eg2/src/app/staff/sandbox/sandbox.component.html | 2 ++ 2 files changed, 19 insertions(+), 3 deletions(-) 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 2664112c78..ce0dc3e2ae 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 @@ -72,6 +72,7 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit { @Input() idlClass: string; @Input() idlField: string; + @Input() idlIncludeLibraryInLabel: string; @Input() asyncDataSource: (term: string) => Observable<ComboboxEntry>; // If true, an async data search is allowed to fetch all @@ -152,9 +153,22 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit { const extra_args = { order_by : {} }; args[field] = {'ilike': `%${term}%`}; // could -or search on label extra_args['order_by'][this.idlClass] = field; - return this.pcrud.search(this.idlClass, args, extra_args).pipe(map(data => { - return {id: data[pkeyField](), label: data[field]()}; - })); + if (this.idlIncludeLibraryInLabel) { + extra_args['flesh'] = 1; + const flesh_fields: Object = {}; + flesh_fields[this.idlClass] = [ this.idlIncludeLibraryInLabel ]; + extra_args['flesh_fields'] = flesh_fields; + return this.pcrud.search(this.idlClass, args, extra_args).pipe(map(data => { + return { + id: data[pkeyField](), + label: data[field]() + ' (' + data[this.idlIncludeLibraryInLabel]().shortname() + ')' + }; + })); + } else { + return this.pcrud.search(this.idlClass, args, extra_args).pipe(map(data => { + return {id: data[pkeyField](), label: data[field]()}; + })); + } }; } } 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 85585f9836..3e2985606a 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 @@ -110,6 +110,8 @@ </eg-combobox> </div> <div class="col-lg-3"> + <eg-combobox placeholder="Combobox with @idlClass = 'acpl'" [idlClass]="'acpl'" idlIncludeLibraryInLabel="owning_lib" [asyncSupportsEmptyTermClick]="true"> + </eg-combobox> </div> </div> <!-- /Progress Dialog Experiments ----------------------------- --> -- 2.11.0