Compare commits

...

5 Commits

5 changed files with 55 additions and 36 deletions

View File

@ -6,7 +6,7 @@
"@auth0/auth0-react": "1.10.2",
"@emotion/react": "11.7.1",
"@emotion/styled": "11.6.0",
"@kingsrook/qqq-frontend-core": "1.0.80",
"@kingsrook/qqq-frontend-core": "1.0.82",
"@mui/icons-material": "5.4.1",
"@mui/material": "5.11.1",
"@mui/styles": "5.11.1",
@ -56,9 +56,7 @@
"npm-install": "npm install --legacy-peer-deps",
"prepublishOnly": "tsc -p ./ --outDir lib/",
"start": "BROWSER=none react-scripts --max-http-header-size=65535 start",
"test": "react-scripts test",
"cypress:open": "cypress open",
"cypress:run": "cypress run"
"test": "react-scripts test"
},
"eslintConfig": {
"extends": [
@ -86,8 +84,6 @@
"@types/react-table": "7.7.9",
"@typescript-eslint/eslint-plugin": "5.10.2",
"@typescript-eslint/parser": "5.10.2",
"cypress": "11.0.1",
"cypress-wait-for-stable-dom": "0.1.0",
"eslint": "8.8.0",
"eslint-import-resolver-typescript": "2.5.0",
"eslint-plugin-import": "2.25.4",

View File

@ -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;
@ -74,7 +76,7 @@ interface Props
isModal?: boolean;
isWidget?: boolean;
isReport?: boolean;
recordIds?: string | QQueryFilter;
recordIds?: string[] | QQueryFilter;
closeModalHandler?: (event: object, reason: string) => void;
forceReInit?: number;
overrideLabel?: string;
@ -88,6 +90,11 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
{
const processNameParam = useParams().processName;
const processName = process === null ? processNameParam : process.name;
let tableVariantLocalStorageKey: string | null = null;
if(table)
{
tableVariantLocalStorageKey = `${TABLE_VARIANT_LOCAL_STORAGE_KEY_ROOT}.${table.name}`;
}
///////////////////
// process state //
@ -368,15 +375,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<string, any>();
@ -385,7 +392,7 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
formFields[key].possibleValueProps.otherValues.set(otherKey, processValues[otherKey]);
});
}
})
});
}
return (
@ -741,7 +748,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 +801,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<string, any>();
Object.keys(initialValues).forEach((ivKey: any) =>
{
dynamicFormFields[key].possibleValueProps.otherValues.set(ivKey, initialValues[ivKey]);
})
});
}
})
});
////////////////////////////////////////////////////
// disable all fields if this is a bulk edit form //
@ -1075,8 +1082,10 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
let queryStringPairsForInit = [];
if (urlSearchParams.get("recordIds"))
{
const recordIdsFromQueryString = urlSearchParams.get("recordIds").split(",");
const encodedRecordIds = recordIdsFromQueryString.map(r => encodeURIComponent(r)).join(",");
queryStringPairsForInit.push("recordsParam=recordIds");
queryStringPairsForInit.push(`recordIds=${urlSearchParams.get("recordIds")}`);
queryStringPairsForInit.push(`recordIds=${encodedRecordIds}`);
}
else if (urlSearchParams.get("filterJSON"))
{
@ -1090,16 +1099,23 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
// }
else if (recordIds)
{
if (typeof recordIds === "string")
{
queryStringPairsForInit.push("recordsParam=recordIds");
queryStringPairsForInit.push(`recordIds=${recordIds}`);
}
else if (recordIds instanceof QQueryFilter)
if (recordIds instanceof QQueryFilter)
{
queryStringPairsForInit.push("recordsParam=filterJSON");
queryStringPairsForInit.push(`filterJSON=${JSON.stringify(recordIds)}`);
}
else if (typeof recordIds === "object" && recordIds.length)
{
const encodedRecordIds = recordIds.map(r => encodeURIComponent(r)).join(",");
queryStringPairsForInit.push("recordsParam=recordIds");
queryStringPairsForInit.push(`recordIds=${encodedRecordIds}`);
}
}
if (tableVariantLocalStorageKey && localStorage.getItem(tableVariantLocalStorageKey))
{
let tableVariant = JSON.parse(localStorage.getItem(tableVariantLocalStorageKey));
queryStringPairsForInit.push(`tableVariant=${JSON.stringify(tableVariant)}`);
}
try
@ -1147,9 +1163,9 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
}
}
if(tableMetaData)
if (tableMetaData)
{
queryStringPairsForInit.push(`tableName=${tableMetaData.name}`)
queryStringPairsForInit.push(`tableName=${encodeURIComponent(tableMetaData.name)}`);
}
try
@ -1187,6 +1203,12 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
formData.append(key, values[key]);
});
if (tableVariantLocalStorageKey && 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[] = [];

View File

@ -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
{
@ -233,7 +234,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
const [activeModalProcess, setActiveModalProcess] = useState(null as QProcessMetaData);
const [launchingProcess, setLaunchingProcess] = useState(launchProcess);
const [recordIdsForProcess, setRecordIdsForProcess] = useState(null as string | QQueryFilter);
const [recordIdsForProcess, setRecordIdsForProcess] = useState([] as string[] | QQueryFilter);
const [columnStatsFieldName, setColumnStatsFieldName] = useState(null as string);
const [columnStatsField, setColumnStatsField] = useState(null as QFieldMetaData);
const [columnStatsFieldTableName, setColumnStatsFieldTableName] = useState(null as string)
@ -925,11 +926,11 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
{
if (table.primaryKeyField !== "id")
{
navigate(`${metaData.getTablePathByName(tableName)}/${params.row[tableMetaData.primaryKeyField]}`);
navigate(`${metaData.getTablePathByName(tableName)}/${encodeURIComponent(params.row[tableMetaData.primaryKeyField])}`);
}
else
{
navigate(`${metaData.getTablePathByName(tableName)}/${params.id}`);
navigate(`${metaData.getTablePathByName(tableName)}/${encodeURIComponent(params.id)}`);
}
}, 100);
}
@ -1188,17 +1189,17 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
{
if (selectFullFilterState === "filter")
{
return `?recordsParam=filterJSON&filterJSON=${JSON.stringify(buildQFilter(tableMetaData, filterModel))}`;
return `?recordsParam=filterJSON&filterJSON=${encodeURIComponent(JSON.stringify(buildQFilter(tableMetaData, filterModel)))}`;
}
if (selectFullFilterState === "filterSubset")
{
return `?recordsParam=filterJSON&filterJSON=${JSON.stringify(buildQFilter(tableMetaData, filterModel, selectionSubsetSize))}`;
return `?recordsParam=filterJSON&filterJSON=${encodeURIComponent(JSON.stringify(buildQFilter(tableMetaData, filterModel, selectionSubsetSize)))}`;
}
if (selectedIds.length > 0)
{
return `?recordsParam=recordIds&recordIds=${selectedIds.join(",")}`;
return `?recordsParam=recordIds&recordIds=${selectedIds.map(r => encodeURIComponent(r)).join(",")}`;
}
return "";
@ -1216,11 +1217,11 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
}
else if (selectedIds.length > 0)
{
setRecordIdsForProcess(selectedIds.join(","));
setRecordIdsForProcess(selectedIds);
}
else
{
setRecordIdsForProcess("");
setRecordIdsForProcess([]);
}
navigate(`${metaData?.getTablePathByName(tableName)}/${process.name}${getRecordsQueryString()}`);

View File

@ -931,7 +931,7 @@ function RecordView({table, launchProcess}: Props): JSX.Element
activeModalProcess &&
<Modal open={activeModalProcess !== null} onClose={(event, reason) => closeModalProcess(event, reason)}>
<div className="modalProcess">
<ProcessRun process={activeModalProcess} isModal={true} table={tableMetaData} recordIds={id} closeModalHandler={closeModalProcess} />
<ProcessRun process={activeModalProcess} isModal={true} table={tableMetaData} recordIds={[id]} closeModalHandler={closeModalProcess} />
</div>
</Modal>
}

View File

@ -246,7 +246,7 @@ export default class DataGridUtils
if (key === tableMetaData.primaryKeyField && linkBase)
{
column.renderCell = (cellValues: any) => (
<Link to={`${linkBase}${cellValues.value}`} onClick={(e) => e.stopPropagation()}>{cellValues.value}</Link>
<Link to={`${linkBase}${encodeURIComponent(cellValues.value)}`} onClick={(e) => e.stopPropagation()}>{cellValues.value}</Link>
);
}
});