tabby/terminus-terminal/src/components/searchPanel.component.ts
Eugene Pankov 04a0a0cc64 lint
2020-03-01 16:10:45 +01:00

43 lines
1.1 KiB
TypeScript

import { Component, Input, Output, EventEmitter } from '@angular/core'
import { ToastrService } from 'ngx-toastr'
import { Frontend, SearchOptions } from '../frontends/frontend'
@Component({
selector: 'search-panel',
template: require('./searchPanel.component.pug'),
styles: [require('./searchPanel.component.scss')],
})
export class SearchPanelComponent {
@Input() query: string
@Input() frontend: Frontend
notFound = false
options: SearchOptions = {
incremental: true,
}
@Output() close = new EventEmitter()
constructor (
private toastr: ToastrService,
) { }
onQueryChange (): void {
this.notFound = false
this.findNext(true)
}
findNext (incremental = false): void {
if (!this.frontend.findNext(this.query, { ...this.options, incremental: incremental || undefined })) {
this.notFound = true
this.toastr.error('Not found')
}
}
findPrevious (): void {
if (!this.frontend.findPrevious(this.query, this.options)) {
this.notFound = true
this.toastr.error('Not found')
}
}
}