up dropdown listing csc

This commit is contained in:
Tykayn 2025-10-06 18:08:14 +02:00 committed by tykayn
parent 34fa746856
commit ffb9027691
11 changed files with 128 additions and 24 deletions

View file

@ -22,6 +22,7 @@ export class MultiSelector implements OnInit {
@Input() store: any;
@Input() actionTypes: any;
@Output() clickedOnInput = new EventEmitter<any>();
@Output() selectedChoicesChange = new EventEmitter<any>();
@Output() availableChoicesChange = new EventEmitter<any>();
@ -73,6 +74,12 @@ export class MultiSelector implements OnInit {
availableChoicesChangeToggleItem(choice: any) {
this.availableChoicesChange.emit(choice);
console.log('toggle available choice ', choice, 'in filter ', this.label);
// Retire immédiatement l'élément cliqué de la liste des disponibles (feedback UI optimiste)
const clickedValue = typeof choice === 'string' ? choice : choice?.value;
this.availableChoices = (this.availableChoices || []).filter((c: any) => {
const value = typeof c === 'string' ? c : c?.value;
return value !== clickedValue;
});
this.store.dispatch({
type: this.actionTypes.UPDATE_FILTER,
payload: {
@ -83,12 +90,25 @@ export class MultiSelector implements OnInit {
)
}
onClickInput() {
onInputClickedOrFocused(event?: any) {
// Informe le parent que cet input a été cliqué/focus pour fermer les autres dropdowns
this.clickedOnInput.emit({ label: this.label });
if (this.disabled) {
console.info('disabled input');
return;
}
this.displayDropdown = !this.displayDropdown;
console.log('Toggled dropdown:', this.displayDropdown);
this.displayDropdown = true;
}
onClickInput() {
console.log('click dropdown:', this.displayDropdown);
if (this.disabled) {
console.info('disabled input');
return;
}
// Informe le parent pour fermer les autres puis ouvre celui-ci
this.clickedOnInput.emit({ label: this.label });
this.displayDropdown = true;
console.log('Opened dropdown:', this.displayDropdown);
}
}