From c7653c8a96f2b4382b774a646ee03858e8d1cb57 Mon Sep 17 00:00:00 2001 From: nthangeniphumudzo <60381173+nthangeniphumudzo@users.noreply.github.com> Date: Mon, 29 Jul 2024 14:39:06 +0200 Subject: [PATCH] modelTypeExpression fix --- .../designer-components/propertyAutocomplete/index.tsx | 7 ++++++- .../queryBuilder/queryBuilderWithModelType.tsx | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/shesha-reactjs/src/designer-components/propertyAutocomplete/index.tsx b/shesha-reactjs/src/designer-components/propertyAutocomplete/index.tsx index 54471c0a3..f155daaee 100644 --- a/shesha-reactjs/src/designer-components/propertyAutocomplete/index.tsx +++ b/shesha-reactjs/src/designer-components/propertyAutocomplete/index.tsx @@ -24,8 +24,13 @@ export const PropertyAutocompleteComponent: IToolboxComponent> = (props) => { const { formData } = useForm(); const { modelType: modelTypeExpression } = props; - const modelType = evaluateString(modelTypeExpression, { data: formData }); + + let modelType = modelTypeExpression ? evaluateString(modelTypeExpression, { data: formData }) : null; + + + if (typeof formData?.entityTypeShortAlias == 'object' && formData.entityTypeShortAlias.hasOwnProperty('_code')) { + + modelType = new Function('data', formData?.entityTypeShortAlias?._code)({ data: formData }); + } return (