= 1}>
{/* Component to render the joining operator between multiple conditions */}
{props.fields.length > 1 ? (
{props.fields.map((field: any, index: number) => {
if (index == 0) {
return Where;
} else if (index == 1) {
return (
);
} else {
return {logicalFieldValue};
}
})}
) : null}
{props.fields &&
props.fields.length > 0 &&
props.fields.map((field: any, index: number) => {
const fieldValue: whereClauseValueType = props.fields.get(index);
if (!!fieldValue && "children" in fieldValue) {
// If the value contains children in it, that means it is a ConditionBlock
return (
{
e.stopPropagation();
onDeletePressed(index);
}}
size={IconSize.SMALL}
top={"14px"}
/>
);
} else {
// Render a single condition component
return ConditionComponent(
{
onDeletePressed,
field,
formName: props.formName,
comparisonTypes: props.comparisonTypes,
maxWidth: props.maxWidth,
currentNumberOfFields: props.fields.length,
currentNestingLevel: props.currentNestingLevel,
},
index,
);
}
})}
1 ? DropdownWidth + Margin : 0}px`}
>
props.fields.push({ condition: props.comparisonTypes[0].value })
}
>
Add A Condition
{/* Check if the config allows more nesting, if it does, allow for adding more blocks */}
For S3 only 4 nested where
condition group is allowed.
}
disabled={props.currentNestingLevel < props.nestedLevels}
donotUsePortal
position="bottom"
>
{
if (props.currentNestingLevel < props.nestedLevels) {
props.fields.push({
condition: props.logicalTypes[0].value,
children: [
{
condition: props.comparisonTypes[0].value,
},
],
});
}
}}
>
Add A Group Condition
);
}
export default function WhereClauseControl(props: WhereClauseControlProps) {
const {
comparisonTypes, // All possible keys for the comparison
configProperty, // JSON path for the where clause data
formName, // Name of the form, used by redux-form lib to store the data in redux store
logicalTypes, // All possible keys for the logical operators joining multiple conditions
nestedLevels, // Number of nested levels allowed
} = props;
// Max width is designed in a way that the proportion stays same even after nesting
const maxWidth = 60; //in vw
return (