Clean csv values; Update qfc - for audit count fix

This commit is contained in:
2023-05-19 11:51:20 -05:00
parent 61f7339400
commit 3a7cadf5c2
4 changed files with 19 additions and 10 deletions

View File

@ -6,7 +6,7 @@
"@auth0/auth0-react": "1.10.2", "@auth0/auth0-react": "1.10.2",
"@emotion/react": "11.7.1", "@emotion/react": "11.7.1",
"@emotion/styled": "11.6.0", "@emotion/styled": "11.6.0",
"@kingsrook/qqq-frontend-core": "1.0.65", "@kingsrook/qqq-frontend-core": "1.0.66",
"@mui/icons-material": "5.4.1", "@mui/icons-material": "5.4.1",
"@mui/material": "5.11.1", "@mui/material": "5.11.1",
"@mui/styles": "5.11.1", "@mui/styles": "5.11.1",

View File

@ -107,7 +107,7 @@ function TableWidget(props: Props): JSX.Element
{selector: ".button", format: "skip"} {selector: ".button", format: "skip"}
] ]
}); });
csv += `"${text}"`; csv += `"${ValueUtils.cleanForCsv(text)}"`;
} }
csv += "\n"; csv += "\n";
} }

View File

@ -193,16 +193,12 @@ function ColumnStats({tableMetaData, fieldMetaData, fieldTableName, filter}: Pro
const doExport = () => const doExport = () =>
{ {
let csv = `"${fieldMetaData.label}","Count"\n`; let csv = `"${ValueUtils.cleanForCsv(fieldMetaData.label)}","Count"\n`;
for (let i = 0; i < valueCounts.length; i++) for (let i = 0; i < valueCounts.length; i++)
{ {
let fieldValue = valueCounts[i].displayValues.get(fieldMetaData.name); const fieldValue = valueCounts[i].displayValues.get(fieldMetaData.name);
if(fieldValue === undefined) const count = valueCounts[i].values.get("count");
{ csv += `"${ValueUtils.cleanForCsv(fieldValue)}",${count}\n`;
fieldValue = "";
}
csv += `"${fieldValue}",${valueCounts[i].values.get("count")}\n`;
} }
const fileName = tableMetaData.label + " - " + fieldMetaData.label + " Column Stats " + ValueUtils.formatDateTimeForFileName(new Date()) + ".csv"; const fileName = tableMetaData.label + " - " + fieldMetaData.label + " Column Stats " + ValueUtils.formatDateTimeForFileName(new Date()) + ".csv";

View File

@ -418,6 +418,19 @@ class ValueUtils
return toPush; return toPush;
} }
/*******************************************************************************
** for building CSV in frontends, cleanse null & undefined, and escape "'s
*******************************************************************************/
public static cleanForCsv(param: any): string
{
if(param === undefined || param === null)
{
return ("");
}
return (String(param).replaceAll(/"/g, "\"\""));
}
} }
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////