From 01d18902d77f8b68ead0c676968bc50829f8146d Mon Sep 17 00:00:00 2001 From: Tim Chamberlain Date: Wed, 20 Sep 2023 19:52:13 -0500 Subject: [PATCH] more updates to allow process to be manually ran --- src/qqq/pages/processes/ProcessRun.tsx | 37 +++++++++++++++------ src/qqq/pages/records/query/RecordQuery.tsx | 3 +- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/qqq/pages/processes/ProcessRun.tsx b/src/qqq/pages/processes/ProcessRun.tsx index 3952f32..484c8c9 100644 --- a/src/qqq/pages/processes/ProcessRun.tsx +++ b/src/qqq/pages/processes/ProcessRun.tsx @@ -62,10 +62,12 @@ import {GoogleDriveFolderPickerWrapper} from "qqq/components/processes/GoogleDri import ProcessSummaryResults from "qqq/components/processes/ProcessSummaryResults"; import ValidationReview from "qqq/components/processes/ValidationReview"; import BaseLayout from "qqq/layouts/BaseLayout"; +import {TABLE_VARIANT_LOCAL_STORAGE_KEY_ROOT} from "qqq/pages/records/query/RecordQuery"; import Client from "qqq/utils/qqq/Client"; import TableUtils from "qqq/utils/qqq/TableUtils"; import ValueUtils from "qqq/utils/qqq/ValueUtils"; + interface Props { process?: QProcessMetaData; @@ -88,6 +90,7 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is { const processNameParam = useParams().processName; const processName = process === null ? processNameParam : process.name; + const tableVariantLocalStorageKey = `${TABLE_VARIANT_LOCAL_STORAGE_KEY_ROOT}.${table.name}`; /////////////////// // process state // @@ -368,15 +371,15 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is // but our first use case, they're the same, so... this needs fixed. // // they also need to know the 'otherValues' in this process - e.g., for filtering // //////////////////////////////////////////////////////////////////////////////////// - if(formFields && processValues) + if (formFields && processValues) { Object.keys(formFields).forEach((key) => { - if(formFields[key].possibleValueProps) + if (formFields[key].possibleValueProps) { - if(processValues[key]) + if (processValues[key]) { - formFields[key].possibleValueProps.initialDisplayValue = processValues[key] + formFields[key].possibleValueProps.initialDisplayValue = processValues[key]; } formFields[key].possibleValueProps.otherValues = formFields[key].possibleValueProps.otherValues ?? new Map(); @@ -385,7 +388,7 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is formFields[key].possibleValueProps.otherValues.set(otherKey, processValues[otherKey]); }); } - }) + }); } return ( @@ -741,7 +744,7 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is formValidations[fieldName] = validation; }; - if(tableMetaData) + if (tableMetaData) { console.log("Adding table name field... ?", tableMetaData.name); addField("tableName", {type: "hidden", omitFromQDynamicForm: true}, tableMetaData.name, null); @@ -794,15 +797,15 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is //////////////////////////////////////////////////////////////////////////////////// Object.keys(dynamicFormFields).forEach((key: any) => { - if(dynamicFormFields[key].possibleValueProps) + if (dynamicFormFields[key].possibleValueProps) { dynamicFormFields[key].possibleValueProps.otherValues = dynamicFormFields[key].possibleValueProps.otherValues ?? new Map(); Object.keys(initialValues).forEach((ivKey: any) => { dynamicFormFields[key].possibleValueProps.otherValues.set(ivKey, initialValues[ivKey]); - }) + }); } - }) + }); //////////////////////////////////////////////////// // disable all fields if this is a bulk edit form // @@ -1102,6 +1105,12 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is } } + if (localStorage.getItem(tableVariantLocalStorageKey)) + { + let tableVariant = JSON.parse(localStorage.getItem(tableVariantLocalStorageKey)); + queryStringPairsForInit.push(`tableVariant=${JSON.stringify(tableVariant)}`); + } + try { const qInstance = await Client.getInstance().loadMetaData(); @@ -1147,9 +1156,9 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is } } - if(tableMetaData) + if (tableMetaData) { - queryStringPairsForInit.push(`tableName=${tableMetaData.name}`) + queryStringPairsForInit.push(`tableName=${tableMetaData.name}`); } try @@ -1187,6 +1196,12 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is formData.append(key, values[key]); }); + if (localStorage.getItem(tableVariantLocalStorageKey)) + { + let tableVariant = JSON.parse(localStorage.getItem(tableVariantLocalStorageKey)); + formData.append("tableVariant", JSON.stringify(tableVariant)); + } + if (doesStepHaveComponent(activeStep, QComponentType.BULK_EDIT_FORM)) { const bulkEditEnabledFields: string[] = []; diff --git a/src/qqq/pages/records/query/RecordQuery.tsx b/src/qqq/pages/records/query/RecordQuery.tsx index 8ad2235..ce76c8e 100644 --- a/src/qqq/pages/records/query/RecordQuery.tsx +++ b/src/qqq/pages/records/query/RecordQuery.tsx @@ -82,7 +82,8 @@ const ROWS_PER_PAGE_LOCAL_STORAGE_KEY_ROOT = "qqq.rowsPerPage"; const PINNED_COLUMNS_LOCAL_STORAGE_KEY_ROOT = "qqq.pinnedColumns"; const SEEN_JOIN_TABLES_LOCAL_STORAGE_KEY_ROOT = "qqq.seenJoinTables"; const DENSITY_LOCAL_STORAGE_KEY_ROOT = "qqq.density"; -const TABLE_VARIANT_LOCAL_STORAGE_KEY_ROOT = "qqq.tableVariant"; + +export const TABLE_VARIANT_LOCAL_STORAGE_KEY_ROOT = "qqq.tableVariant"; interface Props {