From aed1c9d4d081913170bc29f4083c7963af032bc6 Mon Sep 17 00:00:00 2001 From: Darin Kelkhoff Date: Tue, 27 Feb 2024 18:17:51 -0600 Subject: [PATCH] Update to POST (as multipart form) instead of query-string - so yuge filters work. --- src/qqq/pages/processes/ProcessRun.tsx | 32 ++++++++++++-------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/qqq/pages/processes/ProcessRun.tsx b/src/qqq/pages/processes/ProcessRun.tsx index 254396f..78474a3 100644 --- a/src/qqq/pages/processes/ProcessRun.tsx +++ b/src/qqq/pages/processes/ProcessRun.tsx @@ -1089,19 +1089,17 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is (async () => { + const formData = new FormData(); const urlSearchParams = new URLSearchParams(location.search); - 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=${encodedRecordIds}`); + formData.append("recordsParam", "recordIds") + formData.append("recordIds", urlSearchParams.get("recordIds")) } else if (urlSearchParams.get("filterJSON")) { - queryStringPairsForInit.push("recordsParam=filterJSON"); - queryStringPairsForInit.push(`filterJSON=${encodeURIComponent(urlSearchParams.get("filterJSON"))}`); + formData.append("recordsParam", "filterJSON") + formData.append("filterJSON", urlSearchParams.get("filterJSON")); } // todo once saved filters exist //else if(urlSearchParams.get("filterId")) { @@ -1110,23 +1108,23 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is // } else if (recordIds) { - if (recordIds instanceof QQueryFilter) + // @ts-ignore - we're checking to see if recordIds is a QQueryFilter-looking object here. + if (recordIds instanceof QQueryFilter || (typeof recordIds === "object" && recordIds.criteria)) { - queryStringPairsForInit.push("recordsParam=filterJSON"); - queryStringPairsForInit.push(`filterJSON=${encodeURIComponent(JSON.stringify(recordIds))}`); + formData.append("recordsParam", "filterJSON") + formData.append("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}`); + formData.append("recordsParam", "recordIds") + formData.append("recordIds", recordIds.join(",")) } } if (tableVariantLocalStorageKey && localStorage.getItem(tableVariantLocalStorageKey)) { let tableVariant = JSON.parse(localStorage.getItem(tableVariantLocalStorageKey)); - queryStringPairsForInit.push(`tableVariant=${encodeURIComponent(JSON.stringify(tableVariant))}`); + formData.append("tableVariant", JSON.stringify(tableVariant)); } try @@ -1170,18 +1168,18 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is { for (let key in defaultProcessValues) { - queryStringPairsForInit.push(`${key}=${encodeURIComponent(defaultProcessValues[key])}`); + formData.append(key, defaultProcessValues[key]); } } if (tableMetaData) { - queryStringPairsForInit.push(`tableName=${encodeURIComponent(tableMetaData.name)}`); + formData.append("tableName", tableMetaData.name); } try { - const processResponse = await Client.getInstance().processInit(processName, queryStringPairsForInit.join("&")); + const processResponse = await Client.getInstance().processInit(processName, formData); setProcessUUID(processResponse.processUUID); setLastProcessResponse(processResponse); }