Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
activateFilter() {
let searchFields: string[] = this.filterBy.split(',');
if (this.options && this.options.length) {
if (this.group) {
let filteredGroups = [];
for (let optgroup of this.options) {
let filteredSubOptions = FilterUtils.filter(optgroup.items, searchFields, this.filterValue, this.filterMatchMode);
if (filteredSubOptions && filteredSubOptions.length) {
filteredGroups.push({
label: optgroup.label,
value: optgroup.value,
items: filteredSubOptions
});
}
}
this.optionsToDisplay = filteredGroups;
}
else {
this.optionsToDisplay = FilterUtils.filter(this.options, searchFields, this.filterValue, this.filterMatchMode);
}
this.optionsChanged = true;
let filteredGroups = [];
for (let optgroup of this.options) {
let filteredSubOptions = FilterUtils.filter(optgroup.items, searchFields, this.filterValue, this.filterMatchMode);
if (filteredSubOptions && filteredSubOptions.length) {
filteredGroups.push({
label: optgroup.label,
value: optgroup.value,
items: filteredSubOptions
});
}
}
this.optionsToDisplay = filteredGroups;
}
else {
this.optionsToDisplay = FilterUtils.filter(this.options, searchFields, this.filterValue, this.filterMatchMode);
}
this.optionsChanged = true;
}
}