From: Bill Erickson Date: Tue, 22 Jun 2021 15:42:00 +0000 (-0400) Subject: LP1929741 Combobox supports startsWith search X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e451047f83ed46cf909a654bec7da16723d8fe76;p=working%2FEvergreen.git LP1929741 Combobox supports startsWith search In lieu of the default behavor of the typeahead, which does a 'contains' search. 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 7ddd3eda00..3a27ff8500 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 @@ -75,6 +75,10 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit, AfterVie // If true, applies form-control-sm CSS @Input() smallFormControl = false; + // If true, the typeahead only matches values that start with + // the value typed as opposed to a 'contains' match. + @Input() startsWith = false; + // Add a 'required' attribute to the input isRequired: boolean; @Input() set required(r: boolean) { @@ -517,7 +521,11 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit, AfterVie // text entered. return this.entrylist.filter(entry => { const label = entry.label || entry.id; - return label.toLowerCase().indexOf(term.toLowerCase()) > -1; + if (this.startsWith) { + return label.toLowerCase().startsWith(term.toLowerCase()); + } else { + return label.toLowerCase().indexOf(term.toLowerCase()) > -1; + } }); }) );