diff options
Diffstat (limited to 'client/src/app/header/suggestion.component.ts')
-rw-r--r-- | client/src/app/header/suggestion.component.ts | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/client/src/app/header/suggestion.component.ts b/client/src/app/header/suggestion.component.ts new file mode 100644 index 000000000..69641b511 --- /dev/null +++ b/client/src/app/header/suggestion.component.ts | |||
@@ -0,0 +1,37 @@ | |||
1 | import { Input, Component, Output, EventEmitter, OnInit, ChangeDetectionStrategy } from '@angular/core' | ||
2 | import { RouterLink } from '@angular/router' | ||
3 | import { ListKeyManagerOption } from '@angular/cdk/a11y' | ||
4 | |||
5 | export type Result = { | ||
6 | text: string | ||
7 | type: 'channel' | 'suggestion' | 'search-channel' | 'search-instance' | 'search-global' | 'search-any' | ||
8 | routerLink?: RouterLink, | ||
9 | default?: boolean | ||
10 | } | ||
11 | |||
12 | @Component({ | ||
13 | selector: 'my-suggestion', | ||
14 | templateUrl: './suggestion.component.html', | ||
15 | styleUrls: [ './suggestion.component.scss' ], | ||
16 | changeDetection: ChangeDetectionStrategy.OnPush | ||
17 | }) | ||
18 | export class SuggestionComponent implements OnInit, ListKeyManagerOption { | ||
19 | @Input() result: Result | ||
20 | @Input() highlight: string | ||
21 | @Output() selected = new EventEmitter() | ||
22 | |||
23 | disabled = false | ||
24 | active = false | ||
25 | |||
26 | getLabel () { | ||
27 | return this.result.text | ||
28 | } | ||
29 | |||
30 | ngOnInit () { | ||
31 | if (this.result.default) this.active = true | ||
32 | } | ||
33 | |||
34 | selectItem () { | ||
35 | this.selected.emit(this.result) | ||
36 | } | ||
37 | } | ||