aboutsummaryrefslogblamecommitdiffhomepage
path: root/client/src/app/header/suggestion.component.ts
blob: c874212a5a9ea51556307014bcb186c7a62c8c6b (plain) (tree)
1
2
3
4
5
6
7
8
9
                                                        

                                                        
 
                                 
              


                             

 

                                                                      


                                             
                                              

                                                                          
                                    
                            
 


                  




                           
                                               
   
 
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
  }
}