aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/header/suggestion.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/header/suggestion.component.ts')
-rw-r--r--client/src/app/header/suggestion.component.ts48
1 files changed, 48 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..75c44a583
--- /dev/null
+++ b/client/src/app/header/suggestion.component.ts
@@ -0,0 +1,48 @@
1import { Input, Component, Output, EventEmitter, OnInit } from '@angular/core'
2import { RouterLink } from '@angular/router'
3import { I18n } from '@ngx-translate/i18n-polyfill'
4import { ListKeyManagerOption } from '@angular/cdk/a11y'
5
6type Result = {
7 text: string
8 type: 'channel' | 'suggestion' | 'search-channel' | 'search-instance' | 'search-global' | 'search-any'
9 routerLink?: RouterLink
10}
11
12@Component({
13 selector: 'my-suggestion',
14 templateUrl: './suggestion.component.html',
15 styleUrls: [ './suggestion.component.scss' ]
16})
17export class SuggestionComponent implements OnInit, ListKeyManagerOption {
18 @Input() result: Result
19 @Input() highlight: string
20 @Output() selected = new EventEmitter()
21
22 inAllText: string
23 inThisChannelText: string
24 inThisInstanceText: string
25
26 disabled = false
27 active = false
28
29 constructor (
30 private i18n: I18n
31 ) {
32 this.inAllText = this.i18n('In the vidiverse')
33 this.inThisChannelText = this.i18n('In this channel')
34 this.inThisInstanceText = this.i18n('In this instance')
35 }
36
37 getLabel () {
38 return this.result.text
39 }
40
41 ngOnInit () {
42 this.active = false
43 }
44
45 selectItem () {
46 this.selected.emit(this.result)
47 }
48}