ng-implementation/my-workspace/projects/sae-lib/inputs/multi-selector/multi-selector.ts

62 lines
1.6 KiB
TypeScript
Raw Normal View History

2025-09-10 16:02:31 +02:00
import {Component, EventEmitter, Input, Output} from '@angular/core';
2025-09-22 14:53:02 +02:00
import {CommonModule} from '@angular/common';
2025-08-22 11:57:56 +02:00
@Component({
selector: 'sae-multi-selector',
2025-09-10 16:02:31 +02:00
imports: [
2025-09-22 14:53:02 +02:00
CommonModule
2025-09-10 16:02:31 +02:00
],
2025-08-22 11:57:56 +02:00
templateUrl: './multi-selector.html',
styleUrl: './multi-selector.scss'
})
export class MultiSelector {
2025-09-10 16:02:31 +02:00
@Input() disabled: boolean = false;
2025-08-22 12:52:30 +02:00
@Input() label!: string;
2025-09-10 16:02:31 +02:00
// @Input() store: any;
// @Input() ActionTypes: any;
@Input() availableChoices: any = ['choix 1', 'choix 2', 'choix 3'];
@Input() selectedChoices: any = ['choix 4', 'choix 5'];
2025-09-17 15:41:04 +02:00
@Input() displayDropdown: boolean = true;
2025-09-15 13:03:21 +02:00
@Input() store: any;
@Input() actionTypes: any;
2025-09-17 15:41:04 +02:00
2025-09-10 16:02:31 +02:00
@Output() selectedChoicesChange = new EventEmitter<any>();
@Output() availableChoicesChange = new EventEmitter<any>();
2025-08-22 11:57:56 +02:00
2025-09-10 16:02:31 +02:00
constructor() {
}
selectedChoicesChangeToggleItem(choice: any) {
console.log('toggle selected choice ', choice, 'in filter ', this.label);
this.selectedChoicesChange.emit(choice);
// console.log(choice);
// this.store.dispatch({
// type: this.ActionTypes.UPDATE_FILTER,
// payload: {
// filter: this.label,
// selectedChoice: choice
// }
// })
}
availableChoicesChangeToggleItem(choice: any) {
this.availableChoicesChange.emit(choice);
console.log('toggle available choice ', choice, 'in filter ', this.label);
// this.store.dispatch({
// type: this.ActionTypes.UPDATE_FILTER,
// payload: {
// filter: this.label,
// availableChoice: choice
// }
// }
// )
}
onClickInput() {
if (this.disabled) return;
this.displayDropdown = !this.displayDropdown
}
2025-08-22 11:57:56 +02:00
}