From e8baf357987abc2257c5f810128f73f21e1f33a7 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 12 Jul 2019 12:37:59 -0400 Subject: [PATCH] LP1825851 Combobox display template option Signed-off-by: Bill Erickson --- Open-ILS/src/eg2/src/app/share/combobox/combobox.component.html | 4 ++-- Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.html b/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.html index 0a5deeeb8c..821244c25e 100644 --- a/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.html +++ b/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.html @@ -1,6 +1,6 @@ - + {{r.label || r.id}} @@ -14,7 +14,7 @@ [required]="isRequired" [(ngModel)]="selected" [ngbTypeahead]="filter" - [resultTemplate]="displayTemplate" + [resultTemplate]=" displayTemplate || defaultDisplayTemplate" [inputFormatter]="formatDisplayString" (click)="click$.next($event.target.value)" (blur)="onBlur()" 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 63f964ef81..6995043329 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 @@ -3,7 +3,8 @@ * * */ -import {Component, OnInit, Input, Output, ViewChild, EventEmitter, ElementRef} from '@angular/core'; +import {Component, OnInit, Input, Output, ViewChild, + TemplateRef, EventEmitter, ElementRef} from '@angular/core'; import {Observable, of, Subject} from 'rxjs'; import {map, tap, reduce, mergeMap, mapTo, debounceTime, distinctUntilChanged, merge, filter} from 'rxjs/operators'; import {NgbTypeahead, NgbTypeaheadSelectItemEvent} from '@ng-bootstrap/ng-bootstrap'; @@ -83,6 +84,9 @@ export class ComboboxComponent implements OnInit { } } + // When provided use this as the display template for each entry. + @Input() displayTemplate: TemplateRef; + // Emitted when the value is changed via UI. // When the UI value is cleared, null is emitted. @Output() onChange: EventEmitter; -- 2.11.0