From 01916286b07507648bf8cad6ea8cba55171594cd Mon Sep 17 00:00:00 2001 From: Darin Kelkhoff Date: Fri, 23 Sep 2022 10:35:24 -0500 Subject: [PATCH] Add QGoogleDriveFolderPicker --- package.json | 3 +- src/qqq/components/ProcessLinkCard/index.tsx | 4 +- src/qqq/components/QDynamicForm/index.tsx | 7 +- .../components/QGoogleDriveFolderPicker.tsx | 110 ++++++++++++++++++ src/qqq/pages/process-run/index.tsx | 55 ++++++--- 5 files changed, 158 insertions(+), 21 deletions(-) create mode 100644 src/qqq/pages/process-run/components/QGoogleDriveFolderPicker.tsx diff --git a/package.json b/package.json index f2c6f17..570c6b6 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "@fullcalendar/interaction": "5.10.0", "@fullcalendar/react": "5.10.0", "@fullcalendar/timegrid": "5.10.0", - "@kingsrook/qqq-frontend-core": "1.0.17", + "@kingsrook/qqq-frontend-core": "1.0.20", "@mui/icons-material": "5.4.1", "@mui/material": "5.4.1", "@mui/styled-engine": "5.4.1", @@ -45,6 +45,7 @@ "react-dom": "17.0.2", "react-flatpickr": "3.10.7", "react-github-btn": "1.2.1", + "react-google-drive-picker": "^1.2.0", "react-html-parser": "2.0.2", "react-images-viewer": "1.7.1", "react-quill": "1.3.5", diff --git a/src/qqq/components/ProcessLinkCard/index.tsx b/src/qqq/components/ProcessLinkCard/index.tsx index 2588ac0..7444671 100644 --- a/src/qqq/components/ProcessLinkCard/index.tsx +++ b/src/qqq/components/ProcessLinkCard/index.tsx @@ -84,8 +84,8 @@ function ProcessLinkCard({ { isReport - ? `Click here to run the process called ${title}.` - : `Click here to access the ${title} report.` + ? `Click here to access the ${title} report.` + : `Click here to run the process called ${title}.` } {percentage.label} diff --git a/src/qqq/components/QDynamicForm/index.tsx b/src/qqq/components/QDynamicForm/index.tsx index 0107ca2..734e502 100644 --- a/src/qqq/components/QDynamicForm/index.tsx +++ b/src/qqq/components/QDynamicForm/index.tsx @@ -87,6 +87,11 @@ function QDynamicForm(props: Props): JSX.Element values[fieldName] = ""; } + if (field.omitFromQDynamicForm) + { + return null; + } + if (field.type === "file") { return ( @@ -95,7 +100,7 @@ function QDynamicForm(props: Props): JSX.Element + + {selectedGoogleFolderName} + + + + {/* + + + {errors[fieldName] && You must select a file to proceed} + + + */} + + + ); +} diff --git a/src/qqq/pages/process-run/index.tsx b/src/qqq/pages/process-run/index.tsx index 8a3db4d..16ed041 100644 --- a/src/qqq/pages/process-run/index.tsx +++ b/src/qqq/pages/process-run/index.tsx @@ -54,6 +54,7 @@ import MDBox from "qqq/components/Temporary/MDBox"; import MDButton from "qqq/components/Temporary/MDButton"; import MDProgress from "qqq/components/Temporary/MDProgress"; import MDTypography from "qqq/components/Temporary/MDTypography"; +import {QGoogleDriveFolderPicker} from "qqq/pages/process-run/components/QGoogleDriveFolderPicker"; import QValidationReview from "qqq/pages/process-run/components/QValidationReview"; import QClient from "qqq/utils/QClient"; import QValueUtils from "qqq/utils/QValueUtils"; @@ -393,6 +394,11 @@ function ProcessRun({process, defaultProcessValues}: Props): JSX.Element ) } + { + component.type === QComponentType.GOOGLE_DRIVE_SELECT_FOLDER && ( + + ) + } { component.type === QComponentType.RECORD_LIST && step.recordListFields && recordConfig.columns && (
@@ -510,6 +516,7 @@ function ProcessRun({process, defaultProcessValues}: Props): JSX.Element if (newIndex === null) { setProcessError(`Unknown process step ${newStep}.`); + return; } setActiveStepIndex(newIndex); setOverrideOnLastStep(null); @@ -520,15 +527,20 @@ function ProcessRun({process, defaultProcessValues}: Props): JSX.Element setActiveStep(activeStep); setFormId(activeStep.name); + let dynamicFormFields: any = {}; + let formValidations: any = {}; + let initialValues: any = {}; + /////////////////////////////////////////////////// // if this step has form fields, set up the form // /////////////////////////////////////////////////// if (activeStep.formFields || processValues.inputFieldList) { let fullFieldList = getFullFieldList(activeStep, processValues); - const {dynamicFormFields, formValidations} = DynamicFormUtils.getFormData(fullFieldList); + const formData = DynamicFormUtils.getFormData(fullFieldList); + dynamicFormFields = formData.dynamicFormFields; + formValidations = formData.formValidations; - const initialValues: any = {}; fullFieldList.forEach((field) => { initialValues[field.name] = processValues[field.name]; @@ -548,27 +560,36 @@ function ProcessRun({process, defaultProcessValues}: Props): JSX.Element }); setDisabledBulkEditFields(newDisabledBulkEditFields); } - - setFormFields(dynamicFormFields); - setInitialValues(initialValues); - setValidationScheme(Yup.object().shape(formValidations)); - setValidationFunction(null); } - else if (doesStepHaveComponent(activeStep, QComponentType.VALIDATION_REVIEW_SCREEN)) + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // define an inner function here, for adding more fields to the form, if any components have form fields built into them // + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + const addField = (fieldName: string, dynamicFormValue: any, initialValue: any, validation: any) => { - //////////////////////////////////////// - // this component requires this field // - //////////////////////////////////////// - const dynamicFormFields: any = {}; - dynamicFormFields.doFullValidation = {type: "radio"}; + dynamicFormFields[fieldName] = dynamicFormValue; + initialValues[fieldName] = initialValue; + formValidations[fieldName] = validation; + } - const initialValues: any = {}; - initialValues.doFullValidation = "true"; + if (doesStepHaveComponent(activeStep, QComponentType.VALIDATION_REVIEW_SCREEN)) + { + addField("doFullValidation", {type: "radio"}, "true", null); setOverrideOnLastStep(false); + } - const formValidations: any = {}; - formValidations.doFullValidation = null; + if (doesStepHaveComponent(activeStep, QComponentType.GOOGLE_DRIVE_SELECT_FOLDER)) + { + addField("googleDriveAccessToken", {type: "hidden", omitFromQDynamicForm: true}, null, null); + addField("googleDriveFolderId", {type: "hidden", omitFromQDynamicForm: true}, null, null); + addField("googleDriveFolderName", {type: "hidden", omitFromQDynamicForm: true}, null, null); + } + if(Object.keys(dynamicFormFields).length > 0) + { + /////////////////////////////////////////// + // if there are form fields, set them up // + /////////////////////////////////////////// setFormFields(dynamicFormFields); setInitialValues(initialValues); setValidationScheme(Yup.object().shape(formValidations));