]>
Commit | Line | Data |
---|---|---|
9b8a7aa8 | 1 | import { Input, Component, Output, EventEmitter, OnInit, ChangeDetectionStrategy } from '@angular/core' |
6af662a5 | 2 | import { RouterLink } from '@angular/router' |
6af662a5 RK |
3 | import { ListKeyManagerOption } from '@angular/cdk/a11y' |
4 | ||
52cc0d54 | 5 | export 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 | }) |
18 | export 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 | } |