Linked checkboxes to "download selected" button

This commit is contained in:
Geomitron
2020-02-10 00:43:39 -05:00
parent 1e16371958
commit a98b03dcd4
12 changed files with 105 additions and 36 deletions

View File

@@ -1,5 +1,6 @@
import { Component, AfterViewInit, Input, Output, EventEmitter } from '@angular/core'
import { Component, AfterViewInit, Input, Output, EventEmitter, ViewChildren, QueryList } from '@angular/core'
import { SongResult } from '../../../../electron/shared/interfaces/search.interface'
import { ResultTableRowComponent } from './result-table-row/result-table-row.component'
@Component({
selector: 'app-result-table',
@@ -10,6 +11,10 @@ export class ResultTableComponent implements AfterViewInit {
@Input() results: SongResult[]
@Output() rowClicked = new EventEmitter<SongResult>()
@Output() songChecked = new EventEmitter<SongResult>()
@Output() songUnchecked = new EventEmitter<SongResult>()
@ViewChildren('tableRow') tableRows: QueryList<ResultTableRowComponent>
constructor() { }
@@ -20,4 +25,16 @@ export class ResultTableComponent implements AfterViewInit {
onRowClicked(result: SongResult) {
this.rowClicked.emit(result)
}
onSongChecked(result: SongResult) {
this.songChecked.emit(result)
}
onSongUnchecked(result: SongResult) {
this.songUnchecked.emit(result)
}
checkAll(isChecked: boolean) {
this.tableRows.forEach(row => row.check(isChecked))
}
}