FilterFix/Done

main
Manuel Tauber 2024-03-28 18:03:19 +01:00
parent b90d429a8e
commit 479fe7ce09
1 changed files with 18 additions and 22 deletions

View File

@ -154,39 +154,35 @@ export class MultiselectAutocompleteComponent implements OnInit {
} }
}; };
public toggleAll(): void{ public toggleAll(): void {
this.allSelected = !this.allSelected; this.allSelected = !this.allSelected;
if(this.allSelected == false){
//console.log('####false'+this.allSelected); if (this.allSelected) {
for (const item of this.rawData) { for (const item of this.rawData) {
item.selected = false; const filterExists = this.selectData.some(selectedItem => selectedItem.item === item.item);
const i = this.selectData.findIndex(value => value.item === item.item); if (!filterExists) {
this.selectData.splice(i, 1); item.selected = true;
this.selectData.push(item);
this.selectControl.setValue(this.selectData); }
//this.toggleSelection({'item': item.item, 'selected': false});
} }
this.emitAdjustedData(); } else {
}else{
//console.log('####true'+this.allSelected);
for (const item of this.rawData) { for (const item of this.rawData) {
item.selected = true; const index = this.selectData.findIndex(selectedItem => selectedItem.item === item.item);
this.selectData.push(item); if (index !== -1) {
this.selectControl.setValue(this.selectData); item.selected = false;
this.selectData.splice(index, 1);
//this.toggleSelection({'item': item.item, 'selected': true}); }
} }
// for (let rawItem of this.rawData) {
// rawItem.selected = false;
// }
this.emitAdjustedData();
} }
this.selectControl.setValue(this.selectData);
this.emitAdjustedData();
this.evaluateIndeterminate(); this.evaluateIndeterminate();
} }
public showCheckBox(): void{ public showCheckBox(): void{
this.showCheckbox = true; this.showCheckbox = true;
//console.log("####") //console.log("####")