fix: added condition for where clause evaluated value binding path (#10308)

This commit is contained in:
Aman Agarwal 2022-01-13 14:22:00 +05:30 committed by GitHub
parent 33a4c74994
commit 8cc35e797e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,8 +42,7 @@ export const getBindingPathsOfAction = (
formConfig.evaluationSubstitutionType,
);
}
}
if (formConfig.controlType === "ARRAY_FIELD") {
} else if (formConfig.controlType === "ARRAY_FIELD") {
let actionValue = _.get(action, formConfig.configProperty);
if (Array.isArray(actionValue)) {
actionValue = actionValue.filter((val) => val);
@ -63,6 +62,54 @@ export const getBindingPathsOfAction = (
});
}
}
} else if (formConfig.controlType === "WHERE_CLAUSE") {
const recursiveFindBindingPathsForWhereClause = (
newConfigPath: string,
actionValue: any,
) => {
if (
actionValue &&
actionValue.hasOwnProperty("children") &&
Array.isArray(actionValue.children)
) {
actionValue.children.forEach((value: any, index: number) => {
recursiveFindBindingPathsForWhereClause(
`${newConfigPath}.children[${index}]`,
value,
);
});
} else {
if (actionValue.hasOwnProperty("key")) {
bindingPaths[
`${newConfigPath}.key`
] = getCorrectEvaluationSubstitutionType(
formConfig.evaluationSubstitutionType,
);
}
if (actionValue.hasOwnProperty("value")) {
bindingPaths[
`${newConfigPath}.value`
] = getCorrectEvaluationSubstitutionType(
formConfig.evaluationSubstitutionType,
);
}
}
};
const actionValue = _.get(action, formConfig.configProperty);
if (
actionValue &&
actionValue.hasOwnProperty("children") &&
Array.isArray(actionValue.children)
) {
actionValue.children.forEach((value: any, index: number) => {
recursiveFindBindingPathsForWhereClause(
`${configPath}.children[${index}]`,
value,
);
});
}
}
}
};