freetext?: boolean;
userdata?: any; // opaque external value; ignored by this component.
fm?: IdlObject;
+ disabled?: boolean;
}
@Directive({
this.isRequired = r;
}
+ // Array of entry identifiers to disable in the selector
+ @Input() disableEntries: any[] = [];
+
// Disable the input
isDisabled: boolean;
@Input() set disabled(d: boolean) {
});
}
+ // NgbTypeahead doesn't offer a way to style the dropdown
+ // button directly, so we have to reach up and style it ourselves.
+ applyDisableStyle() {
+ this.disableEntries.forEach(id => {
+ const node = document.getElementById(`${this.domId}-${id}`);
+ if (node) {
+ const button = node.parentNode as HTMLElement;
+ button.classList.add('disabled');
+ }
+ });
+ }
+
filter = (text$: Observable<string>): Observable<ComboboxEntry[]> => {
return text$.pipe(
debounceTime(200),
// click action occurred.
if (term === '') { return []; }
+ // Give the typeahead a chance to open before applying
+ // the disabled entry styling.
+ setTimeout(() => this.applyDisableStyle());
+
// In sync-data mode, a click displays the full list.
if (term === '_CLICK_' && !this.asyncDataSource) {
return this.entrylist;