mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-18 05:10:45 +00:00
CE-1955 Add helpContent to hasHeaderRow and layout fields
This commit is contained in:
@ -20,7 +20,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {QFieldMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData";
|
import {QFieldMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData";
|
||||||
|
import {QFieldType} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldType";
|
||||||
|
import {QFrontendStepMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFrontendStepMetaData";
|
||||||
import {QInstance} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QInstance";
|
import {QInstance} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QInstance";
|
||||||
|
import {QProcessMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QProcessMetaData";
|
||||||
import {QTableMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QTableMetaData";
|
import {QTableMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QTableMetaData";
|
||||||
import {QRecord} from "@kingsrook/qqq-frontend-core/lib/model/QRecord";
|
import {QRecord} from "@kingsrook/qqq-frontend-core/lib/model/QRecord";
|
||||||
import Autocomplete from "@mui/material/Autocomplete";
|
import Autocomplete from "@mui/material/Autocomplete";
|
||||||
@ -31,27 +34,30 @@ import {useFormikContext} from "formik";
|
|||||||
import {DynamicFormFieldLabel} from "qqq/components/forms/DynamicForm";
|
import {DynamicFormFieldLabel} from "qqq/components/forms/DynamicForm";
|
||||||
import QDynamicFormField from "qqq/components/forms/DynamicFormField";
|
import QDynamicFormField from "qqq/components/forms/DynamicFormField";
|
||||||
import MDTypography from "qqq/components/legacy/MDTypography";
|
import MDTypography from "qqq/components/legacy/MDTypography";
|
||||||
|
import HelpContent from "qqq/components/misc/HelpContent";
|
||||||
import SavedBulkLoadProfiles from "qqq/components/misc/SavedBulkLoadProfiles";
|
import SavedBulkLoadProfiles from "qqq/components/misc/SavedBulkLoadProfiles";
|
||||||
import BulkLoadFileMappingFields from "qqq/components/processes/BulkLoadFileMappingFields";
|
import BulkLoadFileMappingFields from "qqq/components/processes/BulkLoadFileMappingFields";
|
||||||
import {BulkLoadField, BulkLoadMapping, BulkLoadProfile, BulkLoadTableStructure, FileDescription, Wrapper} from "qqq/models/processes/BulkLoadModels";
|
import {BulkLoadField, BulkLoadMapping, BulkLoadProfile, BulkLoadTableStructure, FileDescription, Wrapper} from "qqq/models/processes/BulkLoadModels";
|
||||||
import {SubFormPreSubmitCallbackResultType} from "qqq/pages/processes/ProcessRun";
|
import {SubFormPreSubmitCallbackResultType} from "qqq/pages/processes/ProcessRun";
|
||||||
import React, {forwardRef, useEffect, useImperativeHandle, useReducer, useState} from "react";
|
import React, {forwardRef, useImperativeHandle, useReducer, useState} from "react";
|
||||||
import ProcessViewForm from "./ProcessViewForm";
|
import ProcessViewForm from "./ProcessViewForm";
|
||||||
|
|
||||||
|
|
||||||
interface BulkLoadMappingFormProps
|
interface BulkLoadMappingFormProps
|
||||||
{
|
{
|
||||||
processValues: any;
|
processValues: any,
|
||||||
tableMetaData: QTableMetaData;
|
tableMetaData: QTableMetaData,
|
||||||
metaData: QInstance;
|
metaData: QInstance,
|
||||||
setActiveStepLabel: (label: string) => void;
|
setActiveStepLabel: (label: string) => void,
|
||||||
|
frontendStep: QFrontendStepMetaData,
|
||||||
|
processMetaData: QProcessMetaData,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
** process component - screen where user does a bulk-load file mapping.
|
** process component - screen where user does a bulk-load file mapping.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
const BulkLoadFileMappingForm = forwardRef(({processValues, tableMetaData, metaData, setActiveStepLabel}: BulkLoadMappingFormProps, ref) =>
|
const BulkLoadFileMappingForm = forwardRef(({processValues, tableMetaData, metaData, setActiveStepLabel, frontendStep, processMetaData}: BulkLoadMappingFormProps, ref) =>
|
||||||
{
|
{
|
||||||
const {setFieldValue} = useFormikContext();
|
const {setFieldValue} = useFormikContext();
|
||||||
|
|
||||||
@ -208,6 +214,8 @@ const BulkLoadFileMappingForm = forwardRef(({processValues, tableMetaData, metaD
|
|||||||
tableStructure={tableStructure}
|
tableStructure={tableStructure}
|
||||||
fileName={processValues.fileBaseName}
|
fileName={processValues.fileBaseName}
|
||||||
fieldErrors={fieldErrors}
|
fieldErrors={fieldErrors}
|
||||||
|
frontendStep={frontendStep}
|
||||||
|
processMetaData={processMetaData}
|
||||||
forceParentUpdate={() => forceUpdate()}
|
forceParentUpdate={() => forceUpdate()}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@ -226,8 +234,6 @@ const BulkLoadFileMappingForm = forwardRef(({processValues, tableMetaData, metaD
|
|||||||
export default BulkLoadFileMappingForm;
|
export default BulkLoadFileMappingForm;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
interface BulkLoadMappingHeaderProps
|
interface BulkLoadMappingHeaderProps
|
||||||
{
|
{
|
||||||
fileDescription: FileDescription,
|
fileDescription: FileDescription,
|
||||||
@ -235,13 +241,15 @@ interface BulkLoadMappingHeaderProps
|
|||||||
bulkLoadMapping?: BulkLoadMapping,
|
bulkLoadMapping?: BulkLoadMapping,
|
||||||
fieldErrors: { [fieldName: string]: string },
|
fieldErrors: { [fieldName: string]: string },
|
||||||
tableStructure: BulkLoadTableStructure,
|
tableStructure: BulkLoadTableStructure,
|
||||||
forceParentUpdate?: () => void
|
forceParentUpdate?: () => void,
|
||||||
|
frontendStep: QFrontendStepMetaData,
|
||||||
|
processMetaData: QProcessMetaData,
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
** private subcomponent - the header section of the bulk load file mapping screen.
|
** private subcomponent - the header section of the bulk load file mapping screen.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
function BulkLoadMappingHeader({fileDescription, fileName, bulkLoadMapping, fieldErrors, tableStructure, forceParentUpdate}: BulkLoadMappingHeaderProps): JSX.Element
|
function BulkLoadMappingHeader({fileDescription, fileName, bulkLoadMapping, fieldErrors, tableStructure, forceParentUpdate, frontendStep, processMetaData}: BulkLoadMappingHeaderProps): JSX.Element
|
||||||
{
|
{
|
||||||
const viewFields = [
|
const viewFields = [
|
||||||
new QFieldMetaData({name: "fileName", label: "File Name", type: "STRING"}),
|
new QFieldMetaData({name: "fileName", label: "File Name", type: "STRING"}),
|
||||||
@ -255,8 +263,6 @@ function BulkLoadMappingHeader({fileDescription, fileName, bulkLoadMapping, fiel
|
|||||||
|
|
||||||
const hasHeaderRowFormField = {name: "hasHeaderRow", label: "Does the file have a header row?", type: "checkbox", isRequired: true, isEditable: true};
|
const hasHeaderRowFormField = {name: "hasHeaderRow", label: "Does the file have a header row?", type: "checkbox", isRequired: true, isEditable: true};
|
||||||
|
|
||||||
let helpRoles = ["PROCESS_SCREEN", "ALL_SCREENS"];
|
|
||||||
|
|
||||||
const layoutOptions = [
|
const layoutOptions = [
|
||||||
{label: "Flat", id: "FLAT"},
|
{label: "Flat", id: "FLAT"},
|
||||||
{label: "Tall", id: "TALL"},
|
{label: "Tall", id: "TALL"},
|
||||||
@ -270,6 +276,9 @@ function BulkLoadMappingHeader({fileDescription, fileName, bulkLoadMapping, fiel
|
|||||||
|
|
||||||
const selectedLayout = layoutOptions.filter(o => o.id == bulkLoadMapping.layout)[0] ?? null;
|
const selectedLayout = layoutOptions.filter(o => o.id == bulkLoadMapping.layout)[0] ?? null;
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
***************************************************************************/
|
||||||
function hasHeaderRowChanged(newValue: any)
|
function hasHeaderRowChanged(newValue: any)
|
||||||
{
|
{
|
||||||
bulkLoadMapping.hasHeaderRow = newValue;
|
bulkLoadMapping.hasHeaderRow = newValue;
|
||||||
@ -278,6 +287,9 @@ function BulkLoadMappingHeader({fileDescription, fileName, bulkLoadMapping, fiel
|
|||||||
forceParentUpdate();
|
forceParentUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
***************************************************************************/
|
||||||
function layoutChanged(event: any, newValue: any)
|
function layoutChanged(event: any, newValue: any)
|
||||||
{
|
{
|
||||||
bulkLoadMapping.layout = newValue ? newValue.id : null;
|
bulkLoadMapping.layout = newValue ? newValue.id : null;
|
||||||
@ -285,6 +297,25 @@ function BulkLoadMappingHeader({fileDescription, fileName, bulkLoadMapping, fiel
|
|||||||
forceParentUpdate();
|
forceParentUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
***************************************************************************/
|
||||||
|
function getFormattedHelpContent(fieldName: string): JSX.Element
|
||||||
|
{
|
||||||
|
const field = frontendStep?.formFields?.find(f => f.name == fieldName);
|
||||||
|
let helpRoles = ["PROCESS_SCREEN", "ALL_SCREENS"];
|
||||||
|
|
||||||
|
let formattedHelpContent = <HelpContent helpContents={field?.helpContents} roles={helpRoles} helpContentKey={`process:${processMetaData?.name};field:${fieldName}`} />;
|
||||||
|
if (formattedHelpContent)
|
||||||
|
{
|
||||||
|
const mt = field && field.type == QFieldType.BOOLEAN ? "-0.5rem" : "0.5rem";
|
||||||
|
|
||||||
|
return <Box color="#757575" fontSize="0.875rem" mt={mt}>{formattedHelpContent}</Box>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<h5>File Details</h5>
|
<h5>File Details</h5>
|
||||||
@ -301,6 +332,7 @@ function BulkLoadMappingHeader({fileDescription, fileName, bulkLoadMapping, fiel
|
|||||||
{<div className="fieldErrorMessage">{fieldErrors.hasHeaderRow}</div>}
|
{<div className="fieldErrorMessage">{fieldErrors.hasHeaderRow}</div>}
|
||||||
</MDTypography>
|
</MDTypography>
|
||||||
}
|
}
|
||||||
|
{getFormattedHelpContent("hasHeaderRow")}
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} md={6}>
|
<Grid item xs={12} md={6}>
|
||||||
<DynamicFormFieldLabel name={"layout"} label={"File Layout *"} />
|
<DynamicFormFieldLabel name={"layout"} label={"File Layout *"} />
|
||||||
@ -322,6 +354,7 @@ function BulkLoadMappingHeader({fileDescription, fileName, bulkLoadMapping, fiel
|
|||||||
{<div className="fieldErrorMessage">{fieldErrors.layout}</div>}
|
{<div className="fieldErrorMessage">{fieldErrors.layout}</div>}
|
||||||
</MDTypography>
|
</MDTypography>
|
||||||
}
|
}
|
||||||
|
{getFormattedHelpContent("layout")}
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Box>
|
</Box>
|
||||||
@ -330,7 +363,6 @@ function BulkLoadMappingHeader({fileDescription, fileName, bulkLoadMapping, fiel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
interface BulkLoadMappingFilePreviewProps
|
interface BulkLoadMappingFilePreviewProps
|
||||||
{
|
{
|
||||||
fileDescription: FileDescription;
|
fileDescription: FileDescription;
|
||||||
|
@ -1032,9 +1032,11 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
|
|||||||
<BulkLoadFileMappingForm
|
<BulkLoadFileMappingForm
|
||||||
processValues={processValues}
|
processValues={processValues}
|
||||||
tableMetaData={tableMetaData}
|
tableMetaData={tableMetaData}
|
||||||
|
processMetaData={processMetaData}
|
||||||
metaData={qInstance}
|
metaData={qInstance}
|
||||||
ref={bulkLoadFileMappingFormRef}
|
ref={bulkLoadFileMappingFormRef}
|
||||||
setActiveStepLabel={setActiveStepLabel}
|
setActiveStepLabel={setActiveStepLabel}
|
||||||
|
frontendStep={activeStep}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -2220,7 +2222,7 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
|
|||||||
if (isModal)
|
if (isModal)
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
<Box sx={{position: "absolute", overflowY: "auto", maxHeight: "100%", width: "100%"}}>
|
<Box sx={{position: "absolute", overflowY: "auto", maxHeight: "100%", width: "100%"}} id="modalProcessScrollContainer">
|
||||||
{body}
|
{body}
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user