From 8354f81eca58ab0597994d990408b6274717668f Mon Sep 17 00:00:00 2001 From: Tim Chamberlain Date: Thu, 7 Jul 2022 15:15:13 -0500 Subject: [PATCH] QQQ-21: fixed isRequired being double checked --- .eslintrc.json | 1 + src/qqq/components/QDynamicForm/index.tsx | 1 - .../components/QDynamicForm/utils/DynamicFormUtils.ts | 7 ++++++- src/qqq/pages/process-run/index.tsx | 11 ++++------- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 83d4599..f4ae317 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -25,6 +25,7 @@ "no-shadow": "off", "no-unused-vars": "off", "spaced-comment": "off", + "object-shorthand": "off", "react/jsx-props-no-spreading": "off", "react/react-in-jsx-scope": "off", "import/extensions": [ diff --git a/src/qqq/components/QDynamicForm/index.tsx b/src/qqq/components/QDynamicForm/index.tsx index ce5c695..ceb7da4 100644 --- a/src/qqq/components/QDynamicForm/index.tsx +++ b/src/qqq/components/QDynamicForm/index.tsx @@ -70,7 +70,6 @@ function QDynamicForm(props: Props): JSX.Element { return ( . */ +// misc imports import * as Yup from "yup"; +// qqq imports import { QFieldMetaData } from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData"; import { QFieldType } from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldType"; @@ -55,9 +57,12 @@ class DynamicFormUtils { fieldType = "text"; } + let label = field.label ? field.label : field.name; + label += field.isRequired ? " *" : ""; + dynamicFormFields[field.name] = { name: field.name, - label: field.label ? field.label : field.name, + label: label, isRequired: field.isRequired, type: fieldType, // todo invalidMsg: "Zipcode is not valid (e.g. 70000).", diff --git a/src/qqq/pages/process-run/index.tsx b/src/qqq/pages/process-run/index.tsx index a926fd6..aa0f38d 100644 --- a/src/qqq/pages/process-run/index.tsx +++ b/src/qqq/pages/process-run/index.tsx @@ -91,19 +91,16 @@ function ProcessRun(): JSX.Element { setActiveStep(activeStep); setFormId(activeStep.name); - const { dynamicFormFields, formValidations } = DynamicFormUtils.getFormData( - activeStep.formFields - ); - - const formFields: any = {}; const initialValues: any = {}; - const validations: any = {}; - activeStep.formFields.forEach((field) => { // todo - not working - also, needs real value. initialValues[field.name] = "Hi"; }); + const { dynamicFormFields, formValidations } = DynamicFormUtils.getFormData( + activeStep.formFields + ); + setFormFields(dynamicFormFields); setInitialValues(initialValues); setValidations(Yup.object().shape(formValidations));