aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/shared/search-with-autocomplete/search-with-autocomplete.component.ts
blob: ced056d1fc62fcf244ff7846ffbb87bf80e757af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { Component, Input, Output, EventEmitter, ViewEncapsulation } from '@angular/core';
import { SearchBarComponent } from '../search-bar/search-bar.component';

@Component({
    selector: 'search-with-autocomplete',
    templateUrl: './search-with-autocomplete.component.html',
    styleUrls: ['./search-with-autocomplete.component.less'],
    encapsulation: ViewEncapsulation.None
})
export class SearchWithAutoCompleteComponent {

    @Input() searchPlaceholder: string;
    @Input() searchBarClass: string;
    @Input() searchQuery: string;
    @Input() autoCompleteValues: Array<string>;
    @Output() searchChanged: EventEmitter<any> = new EventEmitter<any>();
    @Output() searchButtonClicked: EventEmitter<string> = new EventEmitter<string>();

    searchChange = (searchTerm: string) => {
        this.searchQuery = searchTerm;
        this.searchChanged.emit(searchTerm);
    }

    updateSearch = (searchTerm: string) => {
        this.searchQuery = searchTerm;
        this.searchButtonClicked.emit(searchTerm);
        this.autoCompleteValues = [];
    }
}