mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-16 12:20:43 +00:00
CE-1180 reset formik form values (to latest values from backend) after each backend step
This commit is contained in:
@ -47,12 +47,14 @@ import FormData from "form-data";
|
|||||||
import {Form, Formik} from "formik";
|
import {Form, Formik} from "formik";
|
||||||
import parse from "html-react-parser";
|
import parse from "html-react-parser";
|
||||||
import QContext from "QContext";
|
import QContext from "QContext";
|
||||||
|
import colors from "qqq/assets/theme/base/colors";
|
||||||
import {QCancelButton, QSubmitButton} from "qqq/components/buttons/DefaultButtons";
|
import {QCancelButton, QSubmitButton} from "qqq/components/buttons/DefaultButtons";
|
||||||
import QDynamicForm from "qqq/components/forms/DynamicForm";
|
import QDynamicForm from "qqq/components/forms/DynamicForm";
|
||||||
import DynamicFormUtils from "qqq/components/forms/DynamicFormUtils";
|
import DynamicFormUtils from "qqq/components/forms/DynamicFormUtils";
|
||||||
import MDButton from "qqq/components/legacy/MDButton";
|
import MDButton from "qqq/components/legacy/MDButton";
|
||||||
import MDProgress from "qqq/components/legacy/MDProgress";
|
import MDProgress from "qqq/components/legacy/MDProgress";
|
||||||
import MDTypography from "qqq/components/legacy/MDTypography";
|
import MDTypography from "qqq/components/legacy/MDTypography";
|
||||||
|
import HelpContent from "qqq/components/misc/HelpContent";
|
||||||
import QRecordSidebar from "qqq/components/misc/RecordSidebar";
|
import QRecordSidebar from "qqq/components/misc/RecordSidebar";
|
||||||
import {GoogleDriveFolderPickerWrapper} from "qqq/components/processes/GoogleDriveFolderPickerWrapper";
|
import {GoogleDriveFolderPickerWrapper} from "qqq/components/processes/GoogleDriveFolderPickerWrapper";
|
||||||
import ProcessSummaryResults from "qqq/components/processes/ProcessSummaryResults";
|
import ProcessSummaryResults from "qqq/components/processes/ProcessSummaryResults";
|
||||||
@ -86,6 +88,14 @@ const INITIAL_RETRY_MILLIS = 1_500;
|
|||||||
const RETRY_MAX_MILLIS = 12_000;
|
const RETRY_MAX_MILLIS = 12_000;
|
||||||
const BACKOFF_AMOUNT = 1.5;
|
const BACKOFF_AMOUNT = 1.5;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
// define a function that we can make referenes to, which we'll overwrite //
|
||||||
|
// with formik's setFieldValue function, once we're inside formik. //
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
let formikSetFieldValueFunction = (field: string, value: any, shouldValidate?: boolean): void =>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, isReport, recordIds, closeModalHandler, forceReInit, overrideLabel}: Props): JSX.Element
|
function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, isReport, recordIds, closeModalHandler, forceReInit, overrideLabel}: Props): JSX.Element
|
||||||
{
|
{
|
||||||
const processNameParam = useParams().processName;
|
const processNameParam = useParams().processName;
|
||||||
@ -445,6 +455,15 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo not commit - not ready - need process (or screen) meta-data to have helpContents...
|
||||||
|
/*
|
||||||
|
///////////////////////////////
|
||||||
|
// screen-level help content //
|
||||||
|
///////////////////////////////
|
||||||
|
let helpRoles = ["PROCESS_SCREEN", "ALL_SCREENS"];
|
||||||
|
const formattedHelpContent = <HelpContent helpContents={process.helpContents} roles={helpRoles} helpContentKey={`table:${tableName};section:${section.name}`} />;
|
||||||
|
*/
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{
|
{
|
||||||
@ -459,6 +478,16 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
|
|||||||
</MDTypography>
|
</MDTypography>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
// todo not commit - not ready - need process (or screen) meta-data to have helpContents...
|
||||||
|
formattedHelpContent &&
|
||||||
|
<Box px={"1.5rem"} fontSize={"0.875rem"} color={colors.blueGray.main}>
|
||||||
|
{formattedHelpContent}
|
||||||
|
</Box>
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
// render all of the components for this screen //
|
// render all of the components for this screen //
|
||||||
@ -1055,6 +1084,17 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
|
|||||||
setProcessValues(qJobComplete.values);
|
setProcessValues(qJobComplete.values);
|
||||||
setQJobRunning(null);
|
setQJobRunning(null);
|
||||||
|
|
||||||
|
if(formikSetFieldValueFunction)
|
||||||
|
{
|
||||||
|
//////////////////////////////////
|
||||||
|
// reset field values in formik //
|
||||||
|
//////////////////////////////////
|
||||||
|
for (let key in qJobComplete.values)
|
||||||
|
{
|
||||||
|
formikSetFieldValueFunction(key, qJobComplete.values[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// if the process step sent a new frontend-step-list, then refresh what we have in state (constructing new full model objects) //
|
// if the process step sent a new frontend-step-list, then refresh what we have in state (constructing new full model objects) //
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -1423,7 +1463,15 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
|
|||||||
>
|
>
|
||||||
{({
|
{({
|
||||||
values, errors, touched, isSubmitting, setFieldValue,
|
values, errors, touched, isSubmitting, setFieldValue,
|
||||||
}) => (
|
}) =>
|
||||||
|
{
|
||||||
|
///////////////////////////////////////////////////////////////////
|
||||||
|
// once we're in the formik form, use its setFieldValue function //
|
||||||
|
// over top of the default one we created globally //
|
||||||
|
///////////////////////////////////////////////////////////////////
|
||||||
|
formikSetFieldValueFunction = setFieldValue;
|
||||||
|
|
||||||
|
return (
|
||||||
<Form style={formStyles} id={formId} autoComplete="off">
|
<Form style={formStyles} id={formId} autoComplete="off">
|
||||||
<Card sx={mainCardStyles}>
|
<Card sx={mainCardStyles}>
|
||||||
{
|
{
|
||||||
@ -1505,7 +1553,8 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
|
|||||||
</Box>
|
</Box>
|
||||||
</Card>
|
</Card>
|
||||||
</Form>
|
</Form>
|
||||||
)}
|
)
|
||||||
|
}}
|
||||||
</Formik>
|
</Formik>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user