Skip to content

Commit

Permalink
fix(web): Rewrite function for increased readability
Browse files Browse the repository at this point in the history
  • Loading branch information
AVHHogia committed Mar 18, 2021
1 parent 08051a8 commit 277c8b6
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import { testFilterCondition } from './filterUtilities';
*/
export const executeCollectionSearchFilterCondition: FilterCondition = (options: FilterConditionOption) => {
// multiple-select will always return text, so we should make our cell values text as well
const cellValue = (options.cellValue === undefined || options.cellValue === null) ? '' : ((options.operator === 'IN_COLLECTION' || options.operator === 'NOT_IN_COLLECTION') && Array.isArray(options.cellValue)) ? options.cellValue.map(value => `${value}`) : `${options.cellValue}`;
const filterOperator = options.operator;
let cellValue: string | string[];
if (Array.isArray(options.cellValue) && (filterOperator === 'IN_COLLECTION' || filterOperator === 'NOT_IN_COLLECTION')) {
cellValue = (!!options.cellValue.length ? options.cellValue.map(value => `${value}`) : []);
} else {
cellValue = (options.cellValue === undefined || options.cellValue === null) ? '' : `${options.cellValue}`;
}

return testFilterCondition(options.operator || 'IN', cellValue, options.searchTerms || []);
return testFilterCondition(filterOperator || 'IN', cellValue, options.searchTerms || []);
};

0 comments on commit 277c8b6

Please sign in to comment.