mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-04-11 14:19:38 +00:00
Refactor search service
This commit is contained in:
@@ -1,24 +1,40 @@
|
||||
import { Component, Input, Output, EventEmitter, ViewChildren, QueryList, ViewChild } from '@angular/core'
|
||||
import { Component, Output, EventEmitter, ViewChildren, QueryList, ViewChild, OnInit } from '@angular/core'
|
||||
import { SongResult } from '../../../../electron/shared/interfaces/search.interface'
|
||||
import { ResultTableRowComponent } from './result-table-row/result-table-row.component'
|
||||
import { CheckboxDirective } from 'src/app/core/directives/checkbox.directive'
|
||||
import { SearchService } from 'src/app/core/services/search.service'
|
||||
|
||||
@Component({
|
||||
selector: 'app-result-table',
|
||||
templateUrl: './result-table.component.html',
|
||||
styleUrls: ['./result-table.component.scss']
|
||||
})
|
||||
export class ResultTableComponent {
|
||||
@Input() results: SongResult[]
|
||||
|
||||
export class ResultTableComponent implements OnInit {
|
||||
|
||||
@Output() rowClicked = new EventEmitter<SongResult>()
|
||||
@Output() songChecked = new EventEmitter<SongResult>()
|
||||
@Output() songUnchecked = new EventEmitter<SongResult>()
|
||||
|
||||
|
||||
@ViewChild(CheckboxDirective, { static: true }) checkboxColumn: CheckboxDirective
|
||||
@ViewChildren('tableRow') tableRows: QueryList<ResultTableRowComponent>
|
||||
|
||||
results: SongResult[]
|
||||
|
||||
constructor() { }
|
||||
constructor(private searchService: SearchService) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.searchService.onNewSearch(() => {
|
||||
this.checkboxColumn.check(false)
|
||||
this.checkAll(false)
|
||||
})
|
||||
|
||||
this.searchService.onSearchChanged(results => {
|
||||
this.results = results
|
||||
if (this.checkboxColumn.isChecked) {
|
||||
this.checkAll(true)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onRowClicked(result: SongResult) {
|
||||
this.rowClicked.emit(result)
|
||||
@@ -39,8 +55,4 @@ export class ResultTableComponent {
|
||||
onSongsDeselected(songs: SongResult['id'][]) {
|
||||
this.tableRows.forEach(row => row.check(!songs.includes(row.songID)))
|
||||
}
|
||||
|
||||
onNewSearch() {
|
||||
this.checkboxColumn.check(false)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user