]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/header/suggestion.component.ts
Fix search after first type on input
[github/Chocobozzz/PeerTube.git] / client / src / app / header / suggestion.component.ts
CommitLineData
9b8a7aa8 1import { Input, Component, Output, EventEmitter, OnInit, ChangeDetectionStrategy } from '@angular/core'
6af662a5 2import { RouterLink } from '@angular/router'
6af662a5
RK
3import { ListKeyManagerOption } from '@angular/cdk/a11y'
4
52cc0d54 5export type Result = {
6af662a5
RK
6 text: string
7 type: 'channel' | 'suggestion' | 'search-channel' | 'search-instance' | 'search-global' | 'search-any'
52cc0d54
RK
8 routerLink?: RouterLink,
9 default?: boolean
6af662a5
RK
10}
11
12@Component({
13 selector: 'my-suggestion',
14 templateUrl: './suggestion.component.html',
9b8a7aa8
RK
15 styleUrls: [ './suggestion.component.scss' ],
16 changeDetection: ChangeDetectionStrategy.OnPush
6af662a5
RK
17})
18export class SuggestionComponent implements OnInit, ListKeyManagerOption {
19 @Input() result: Result
20 @Input() highlight: string
21 @Output() selected = new EventEmitter()
22
6af662a5
RK
23 disabled = false
24 active = false
25
6af662a5
RK
26 getLabel () {
27 return this.result.text
28 }
29
30 ngOnInit () {
52cc0d54 31 if (this.result.default) this.active = true
6af662a5
RK
32 }
33
34 selectItem () {
35 this.selected.emit(this.result)
36 }
37}