ajout filtrage de multi filtre par input texte
This commit is contained in:
parent
e9d273c5a2
commit
a4645638cd
2 changed files with 29 additions and 3 deletions
|
@ -25,6 +25,8 @@ export class MultiSelector implements OnInit {
|
|||
@Output() selectedChoicesChange = new EventEmitter<any>();
|
||||
@Output() availableChoicesChange = new EventEmitter<any>();
|
||||
|
||||
searchText: string = '';
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
|
@ -33,6 +35,28 @@ export class MultiSelector implements OnInit {
|
|||
|
||||
}
|
||||
|
||||
onSearchInput(event: any) {
|
||||
this.searchText = (event?.target?.value || '').toLowerCase();
|
||||
}
|
||||
|
||||
getFilteredSelectedChoices() {
|
||||
if (!this.searchText) {
|
||||
return this.selectedChoices || [];
|
||||
}
|
||||
return (this.selectedChoices || []).filter((c: any) =>
|
||||
(c?.label || '').toLowerCase().includes(this.searchText)
|
||||
);
|
||||
}
|
||||
|
||||
getFilteredAvailableChoices() {
|
||||
if (!this.searchText) {
|
||||
return this.availableChoices || [];
|
||||
}
|
||||
return (this.availableChoices || []).filter((c: any) =>
|
||||
(c?.label || '').toLowerCase().includes(this.searchText)
|
||||
);
|
||||
}
|
||||
|
||||
selectedChoicesChangeToggleItem(choice: any) {
|
||||
console.log('toggle selected choice ', choice, 'in filter ', this.label);
|
||||
this.selectedChoicesChange.emit(choice);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue