aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/header/suggestion.component.ts
blob: c874212a5a9ea51556307014bcb186c7a62c8c6b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { ListKeyManagerOption } from '@angular/cdk/a11y'
import { Component, Input, OnInit } from '@angular/core'
import { RouterLink } from '@angular/router'

export type SuggestionPayload = {
  text: string
  type: SuggestionPayloadType
  routerLink?: RouterLink
  default: boolean
}

export type SuggestionPayloadType = 'search-instance' | 'search-index'

@Component({
  selector: 'my-suggestion',
  templateUrl: './suggestion.component.html',
  styleUrls: [ './suggestion.component.scss' ]
})
export class SuggestionComponent implements OnInit, ListKeyManagerOption {
  @Input() result: SuggestionPayload
  @Input() highlight: string

  disabled = false
  active = false

  getLabel () {
    return this.result.text
  }

  ngOnInit () {
    if (this.result.default) this.active = true
  }
}