Currently, I have this function that I am refactoring with the goal of making it more concise. For instance, by using a generic function.
setSelectedSearchOptions(optionLabel: string) {
//this.filterSection.reset();
this.selectedOption = optionLabel;
this.selectedSearch = optionLabel;
if (optionLabel === 'Registratie') {
this.setFilterOptions(true, false, false, false, undefined, '', false, false, false, false);
}
if (optionLabel === 'Vcheq') {
this.setFilterOptions(true, false, false, false, undefined, true, false, true, false, false);
}
if (optionLabel === 'Doelen') {
this.setFilterOptions(true, false, false, false, undefined, ',', ',', ',', true, false);
}
}
// Function to set filter options based on input
setFilterOptions(showDateOne: boolean, showDateTwo: boolean, showDateThree: boolean,
buttonFilterDisabled: boolean, startDateValue: any,
isButtonVisible: any, showVcheqCode: boolean, showIndicator: boolean,
showMeasurement: boolean, showChallenge: boolean) {
this.showDatePickerOne = showDateOne;
this.showDatePickerTwo = showDateTwo;
this.showDatePickerThree = showDateThree;
this.buttonFilterDisabled = buttonFilterDisabled;
this.startDate = startDateValue;
this.isButtonVisible = isButtonVisible;
this.showDropdownVcheqCode = showVcheqCode;
this.showDropdownIndicator = showIndicator;
this.showDropdownMeasurement = showMeasurement;
this.showDropdownChallenge = showChallenge;
}
Although, I believe there might be a way to further shorten this function. Any ideas on how to achieve that?
Thank you