Fix checkboxes and bulk download

This commit is contained in:
Geomitron
2023-12-25 10:29:57 -06:00
parent 5644ea2447
commit 199374b2e2
12 changed files with 66 additions and 126 deletions

View File

@@ -1,5 +1,5 @@
<td>
<input #checkAllCheckbox type="checkbox" class="checkbox" (click)="$event.stopPropagation()" [(ngModel)]="selected" />
<input type="checkbox" class="checkbox" (click)="$event.stopPropagation()" [(ngModel)]="selected" />
</td>
<td>
<span *ngIf="song.length > 1" class="rounded-sm bg-accent text-accent-content px-1 mr-1 font-bold">{{ song.length }}</span> {{ song[0].name }}

View File

@@ -13,7 +13,7 @@ export class ResultTableRowComponent implements OnInit {
constructor(private selectionService: SelectionService) { }
ngOnInit() {
this.selectionService.selections[this.groupId] = false
this.selectionService.selections[this.groupId] = this.selectionService.isAllSelected()
}
get groupId() {

View File

@@ -2,7 +2,7 @@
<thead>
<tr>
<th class="collapsing" id="checkboxColumn">
<input #checkAllCheckbox type="checkbox" class="checkbox" (change)="checkAll(checkAllCheckbox.checked)" />
<input type="checkbox" class="checkbox" [(ngModel)]="allSelected" />
</th>
<th [ngClass]="sortDirection" (click)="onColClicked('name')">
Name <i *ngIf="sortColumn === 'name'" class="bi bi-caret-{{ sortDirection === 'ascending' ? 'down' : 'up' }}-fill"></i>

View File

@@ -32,8 +32,13 @@ export class ResultTableComponent implements OnInit {
) { }
ngOnInit() {
this.searchService.searchUpdated.subscribe(() => {
this.searchService.newSearch.subscribe(() => {
this.activeSong = null
this.sortDirection = 'ascending'
this.sortColumn = null
this.updateSort()
})
this.searchService.updateSearch.subscribe(() => {
this.updateSort()
})
}
@@ -65,18 +70,17 @@ export class ResultTableComponent implements OnInit {
private updateSort() {
const col = this.sortColumn
if (col !== null) {
const groupedSongs = sortBy(this.searchService.groupedSongs, song => song[0][col])
const groupedSongs = sortBy(this.searchService.groupedSongs, song => song[0][col]?.toLowerCase())
if (this.sortDirection === 'descending') { groupedSongs.reverse() }
this.searchService.groupedSongs = groupedSongs
}
}
/**
* Called when the user checks the `checkboxColumn`.
*/
checkAll(isChecked: boolean) {
console.log(isChecked)
if (isChecked) {
get allSelected() {
return this.selectionService.isAllSelected()
}
set allSelected(value: boolean) {
if (value) {
this.selectionService.selectAll()
} else {
this.selectionService.deselectAll()