From: Bill Erickson <berickxx@gmail.com>
Date: Fri, 12 Jul 2019 16:37:59 +0000 (-0400)
Subject: LP1825851 Combobox display template option
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=5d15571b2c5099af2883f508997182a3b3b6b61a;p=contrib%2FConifer.git

LP1825851 Combobox display template option

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Kyle Huckins <khuckins@catalyte.io>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
---

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 0f0afde823..83df22e20a 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 @@
 
 <!-- todo disabled -->
-<ng-template #displayTemplate let-r="result">
+<ng-template #defaultDisplayTemplate let-r="result">
 {{r.label || r.id}}
 </ng-template>
 
@@ -14,7 +14,7 @@
     [required]="isRequired"
     [(ngModel)]="selected" 
     [ngbTypeahead]="filter"
-    [resultTemplate]="displayTemplate"
+    [resultTemplate]=" displayTemplate || defaultDisplayTemplate"
     [inputFormatter]="formatDisplayString"
     (click)="onClick($event)"
     (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 0696a989fb..67d73e9cf5 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 @@
  *  <!-- see also <eg-combobox-entry> -->
  * </eg-combobox>
  */
-import {Component, OnInit, Input, Output, ViewChild, EventEmitter, ElementRef, forwardRef} from '@angular/core';
+import {Component, OnInit, Input, Output, ViewChild, 
+    TemplateRef, EventEmitter, ElementRef, forwardRef} from '@angular/core';
 import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
 import {Observable, of, Subject} from 'rxjs';
 import {map, tap, reduce, mergeMap, mapTo, debounceTime, distinctUntilChanged, merge, filter} from 'rxjs/operators';
@@ -99,6 +100,9 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit {
         }
     }
 
+    // When provided use this as the display template for each entry.
+    @Input() displayTemplate: TemplateRef<any>;
+
     // Emitted when the value is changed via UI.
     // When the UI value is cleared, null is emitted.
     @Output() onChange: EventEmitter<ComboboxEntry>;