+ {step.viewFields.map((field: QFieldMetaData) => (
+
+
+ {field.label}
+ :
+
+
+ {formatViewValue(processValues[field.name])}
+
+
+ ))}
+
+ )
+ }
+ {
+ component.type === QComponentType.VALIDATION_REVIEW_SCREEN && (
+
+ {
+ const {value} = event.currentTarget;
+
+ //////////////////////////////////////////////////////////////
+ // call the formik function to set the value in this field. //
+ //////////////////////////////////////////////////////////////
+ setFieldValue("doFullValidation", value);
+
+ // eslint-disable-next-line no-unneeded-ternary
+ setOverrideOnLastStep(value === "true" ? false : true);
+ }}
+ />
+ )
+ }
+ {
+ component.type === QComponentType.PROCESS_SUMMARY_RESULTS && (
+
+ )
+ }
+ {
+ component.type === QComponentType.RECORD_LIST && step.recordListFields && recordConfig.columns && (
+
+ Records
+ {" "}
+
+
+ row.__idForDataGridPro__}
+ paginationMode="server"
+ pagination
+ density="compact"
+ loading={recordConfig.loading}
+ disableColumnFilter
+ />
+
+
+ )
+ }
)))}
- {step.formFields && (
-
- )}
- {step.viewFields && (
-
- {step.viewFields.map((field: QFieldMetaData) => (
-
-
- {field.label}
- :
-
-
- {formatViewValue(processValues[field.name])}
-
-
- ))}
-
- )}
- {(step.recordListFields && recordConfig.columns) && (
-
- Records
- {" "}
-
-
- row.__idForDataGridPro__}
- paginationMode="server"
- pagination
- density="compact"
- loading={recordConfig.loading}
- disableColumnFilter
- />
-
-
- )}
>
);
};
@@ -382,6 +432,7 @@ function ProcessRun({process}: Props): JSX.Element
setProcessError(`Unknown process step ${newStep}.`);
}
setActiveStepIndex(newIndex);
+ setOverrideOnLastStep(null);
if (steps)
{
@@ -424,6 +475,26 @@ function ProcessRun({process}: Props): JSX.Element
setValidationScheme(Yup.object().shape(formValidations));
setValidationFunction(null);
}
+ else if (doesStepHaveComponent(activeStep, QComponentType.VALIDATION_REVIEW_SCREEN))
+ {
+ ////////////////////////////////////////
+ // this component requires this field //
+ ////////////////////////////////////////
+ const dynamicFormFields: any = {};
+ dynamicFormFields.doFullValidation = {type: "radio"};
+
+ const initialValues: any = {};
+ initialValues.doFullValidation = "true";
+ setOverrideOnLastStep(false);
+
+ const formValidations: any = {};
+ formValidations.doFullValidation = null;
+
+ setFormFields(dynamicFormFields);
+ setInitialValues(initialValues);
+ setValidationScheme(Yup.object().shape(formValidations));
+ setValidationFunction(null);
+ }
else
{
/////////////////////////////////////////////////////////////////////////
@@ -502,6 +573,7 @@ function ProcessRun({process}: Props): JSX.Element
);
const {records} = response;
+ setRecords(records);
/////////////////////////////////////////////////////////////////////////////////////////
// re-construct the recordConfig object, so the setState call triggers a new rendering //
@@ -542,6 +614,12 @@ function ProcessRun({process}: Props): JSX.Element
setJobUUID(null);
setNewStep(qJobComplete.nextStep);
setProcessValues(qJobComplete.values);
+ setQJobRunning(null);
+
+ if (activeStep && activeStep.recordListFields)
+ {
+ setNeedRecords(true);
+ }
}
else if (lastProcessResponse instanceof QJobStarted)
{
@@ -562,6 +640,7 @@ function ProcessRun({process}: Props): JSX.Element
console.log(`Got an error from the backend... ${qJobError.error}`);
setJobUUID(null);
setProcessError(qJobError.error);
+ setQJobRunning(null);
}
}
}, [lastProcessResponse]);
@@ -574,13 +653,18 @@ function ProcessRun({process}: Props): JSX.Element
if (needToCheckJobStatus)
{
setNeedToCheckJobStatus(false);
+ if (!processUUID || !jobUUID)
+ {
+ console.log(`Missing processUUID[${processUUID}] or jobUUID[${jobUUID}], so returning without checking job status`);
+ return;
+ }
+
(async () =>
{
setTimeout(async () =>
{
try
{
- console.log("OK");
const processResponse = await QClient.getInstance().processJobStatus(
processName,
processUUID,
@@ -624,8 +708,7 @@ function ProcessRun({process}: Props): JSX.Element
setNeedInitialLoad(false);
(async () =>
{
- const {search} = useLocation();
- const urlSearchParams = new URLSearchParams(search);
+ const urlSearchParams = new URLSearchParams(location.search);
let queryStringForInit = null;
if (urlSearchParams.get("recordIds"))
{
@@ -644,11 +727,35 @@ function ProcessRun({process}: Props): JSX.Element
// queryStringForInit = `recordsParam=filterId&filterId=${urlSearchParams.get("filterId")}`
// }
+ try
+ {
+ const qInstance = await QClient.getInstance().loadMetaData();
+ setQInstance(qInstance);
+ }
+ catch (e)
+ {
+ setProcessError("Error loading process definition.");
+ return;
+ }
+
try
{
const processMetaData = await QClient.getInstance().loadProcessMetaData(processName);
setProcessMetaData(processMetaData);
setSteps(processMetaData.frontendSteps);
+ if (processMetaData.tableName)
+ {
+ try
+ {
+ const tableMetaData = await QClient.getInstance().loadTableMetaData(processMetaData.tableName);
+ setTableMetaData(tableMetaData);
+ }
+ catch (e)
+ {
+ setProcessError("Error loading process's table definition.");
+ return;
+ }
+ }
}
catch (e)
{
@@ -714,6 +821,8 @@ function ProcessRun({process}: Props): JSX.Element
"content-type": "multipart/form-data; boundary=--------------------------320289315924586491558366",
};
+ setProcessValues({});
+ setRecords([]);
setLastProcessResponse(new QJobRunning({message: "Working..."}));
setTimeout(async () =>
@@ -729,15 +838,42 @@ function ProcessRun({process}: Props): JSX.Element
});
};
+ const handleCancelClicked = () =>
+ {
+ const pathParts = location.pathname.split(/\//);
+ pathParts.pop();
+ const path = pathParts.join("/");
+ navigate(path, {replace: true});
+ };
+
+ const mainCardStyles: any = {};
+ mainCardStyles.minHeight = "calc(100vh - 400px)";
+ if (qJobRunning || activeStep === null)
+ {
+ mainCardStyles.background = "none";
+ mainCardStyles.boxShadow = "none";
+ }
+
+ let nextButtonLabel = "Next";
+ let nextButtonIcon = "arrow_forward";
+ if (overrideOnLastStep !== null)
+ {
+ if (overrideOnLastStep)
+ {
+ nextButtonLabel = "Submit";
+ nextButtonIcon = "check";
+ }
+ }
+ else if (onLastStep)
+ {
+ nextButtonLabel = "Submit";
+ nextButtonIcon = "check";
+ }
+
return (
-
+
{({
- values, errors, touched, isSubmitting,
+ values, errors, touched, isSubmitting, setFieldValue,
}) => (