Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function changeSingle (val: string) {
const l = val.split(',').map(v => v.trim());
onChange([l[0]]);
}
function changeRange(val: string, index: number) {
values[index] = val;
onChange(values);
}
function changeList(val: string) {
onChange([...(new Set(val.split(',').map(v => v.trim())))]);
}
// Render specific input type based on operators
if (operator === ConseilOperator.BETWEEN) {
return (
changeRange(val, 0)}
/>
<hr>
{t('components.valueInput.and')}
<hr>
changeRange(val, 1)}
/>
selectedFilters.forEach((filter: Filter) => {
if ((filter.operator === ConseilOperator.BETWEEN || filter.operator === ConseilOperator.IN || filter.operator === 'notin') && filter.values.length === 1) {
return true;
}
if (filter.operator !== ConseilOperator.ISNULL && filter.operator !== 'isnotnull' && (filter.values.length === 0 || filter.values[0].length === 0)) {
return true;
}
let isInvert = false;
let operator: any = filter.operator;
if (filter.operator === 'isnotnull') {
isInvert = true;
operator = ConseilOperator.ISNULL;
} else if (filter.operator === 'noteq') {
operator = ConseilOperator.EQ;
isInvert = true;
} else if (filter.operator === 'notstartWith') {
filters,
operators,
availableValues,
onSubmit,
t
} = this.props;
const entityName = selectedEntity.replace(/_/gi, ' ').slice(0, -1);
const filterLength = filters.length;
let disableAddFilter = true;
const lastFilter: any = filterLength > 0 ? filters[filterLength - 1] : {};
if (filterLength === 0) {
disableAddFilter = false;
} else if (lastFilter.operator === ConseilOperator.ISNULL || lastFilter.operator === 'isnotnull') {
disableAddFilter = false;
} else if(lastFilter.operator === ConseilOperator.BETWEEN) {
disableAddFilter = lastFilter.values.length !== 2;
} else if (lastFilter.values[0] !== '') {
disableAddFilter = false;
}
const newAttributes = attributes.filter((attr: any) => { return !attr.cardinality || attr.cardinality > 1; });
return (
{filters.map((filter: Filter, index) => {
const filterAttr = newAttributes.find(attr => attr.name === filter.name);
return (