mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-04-11 14:19:38 +00:00
Fix checkboxes and bulk download
This commit is contained in:
@@ -2,34 +2,29 @@ import { EventEmitter, Injectable } from '@angular/core'
|
||||
|
||||
import { SearchService } from './search.service'
|
||||
|
||||
// Note: this class prevents event cycles by only emitting events if the checkbox changes
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class SelectionService {
|
||||
|
||||
private allSelected = false
|
||||
private selectAllChangedEmitter = new EventEmitter<boolean>()
|
||||
|
||||
public selections: { [groupId: number]: boolean | undefined } = {}
|
||||
|
||||
constructor(searchService: SearchService) {
|
||||
searchService.searchUpdated.subscribe(() => {
|
||||
searchService.newSearch.subscribe(() => {
|
||||
this.selections = {}
|
||||
this.deselectAll()
|
||||
})
|
||||
}
|
||||
|
||||
getSelectedResults() {
|
||||
// TODO
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return [] as any[] // this.searchResults.filter(result => this.selections[result.id] === true)
|
||||
}
|
||||
|
||||
onSelectAllChanged(callback: (selected: boolean) => void) {
|
||||
this.selectAllChangedEmitter.subscribe(callback)
|
||||
isAllSelected() {
|
||||
return this.allSelected
|
||||
}
|
||||
|
||||
deselectAll() {
|
||||
this.allSelected = false
|
||||
for (const groupId in this.selections) {
|
||||
this.selections[groupId] = false
|
||||
}
|
||||
@@ -37,6 +32,7 @@ export class SelectionService {
|
||||
}
|
||||
|
||||
selectAll() {
|
||||
this.allSelected = true
|
||||
for (const groupId in this.selections) {
|
||||
this.selections[groupId] = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user