]>
Commit | Line | Data |
---|---|---|
6af662a5 RK |
1 | import { Input, Component, Output, EventEmitter, OnInit } from '@angular/core' |
2 | import { RouterLink } from '@angular/router' | |
3 | import { I18n } from '@ngx-translate/i18n-polyfill' | |
4 | import { ListKeyManagerOption } from '@angular/cdk/a11y' | |
5 | ||
52cc0d54 | 6 | export type Result = { |
6af662a5 RK |
7 | text: string |
8 | type: 'channel' | 'suggestion' | 'search-channel' | 'search-instance' | 'search-global' | 'search-any' | |
52cc0d54 RK |
9 | routerLink?: RouterLink, |
10 | default?: boolean | |
6af662a5 RK |
11 | } |
12 | ||
13 | @Component({ | |
14 | selector: 'my-suggestion', | |
15 | templateUrl: './suggestion.component.html', | |
16 | styleUrls: [ './suggestion.component.scss' ] | |
17 | }) | |
18 | export class SuggestionComponent implements OnInit, ListKeyManagerOption { | |
19 | @Input() result: Result | |
20 | @Input() highlight: string | |
21 | @Output() selected = new EventEmitter() | |
22 | ||
23 | inAllText: string | |
24 | inThisChannelText: string | |
25 | inThisInstanceText: string | |
26 | ||
27 | disabled = false | |
28 | active = false | |
29 | ||
30 | constructor ( | |
31 | private i18n: I18n | |
32 | ) { | |
33 | this.inAllText = this.i18n('In the vidiverse') | |
34 | this.inThisChannelText = this.i18n('In this channel') | |
35 | this.inThisInstanceText = this.i18n('In this instance') | |
36 | } | |
37 | ||
38 | getLabel () { | |
39 | return this.result.text | |
40 | } | |
41 | ||
42 | ngOnInit () { | |
52cc0d54 | 43 | if (this.result.default) this.active = true |
6af662a5 RK |
44 | } |
45 | ||
46 | selectItem () { | |
47 | this.selected.emit(this.result) | |
48 | } | |
49 | } |