aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/shared/search-bar/search-bar.component.ts
blob: 2835d20ba4cff2889936f4adf174d05f16707aff (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';

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

    @Input() placeholder: string;
    @Input() class: string;
    @Input() searchQuery: string;
    @Output() searchChanged: EventEmitter<any> = new EventEmitter<any>();
    @Output() searchButtonClicked: EventEmitter<string> = new EventEmitter<string>();

    searchButtonClick = (): void => {
        this.searchButtonClicked.emit(this.searchQuery);
    }

    searchQueryChange = ($event): void => {
        this.searchChanged.emit($event);
    }

    private clearSearchQuery = (): void => {
        this.searchQuery = "";
        this.searchButtonClick();
    }
}