From 0fb14f0e5717bbf070a827de9cdbaff1b4c0a3ae Mon Sep 17 00:00:00 2001 From: Jon Herron Date: Mon, 28 Nov 2022 13:56:45 -0500 Subject: [PATCH] WIP --- .../components/ProcessInstanceListSaveAsReport.tsx | 11 +++++------ .../src/components/ProcessInstanceListTable.tsx | 11 ++++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/spiffworkflow-frontend/src/components/ProcessInstanceListSaveAsReport.tsx b/spiffworkflow-frontend/src/components/ProcessInstanceListSaveAsReport.tsx index a642d4f9..e225d2ff 100644 --- a/spiffworkflow-frontend/src/components/ProcessInstanceListSaveAsReport.tsx +++ b/spiffworkflow-frontend/src/components/ProcessInstanceListSaveAsReport.tsx @@ -11,7 +11,7 @@ import HttpService from '../services/HttpService'; type OwnProps = { onSuccess: (..._args: any[]) => any; - columns: string; + columnArray: { Header: string; accessor: string}; orderBy: string; filterBy: string; buttonText?: string; @@ -19,10 +19,10 @@ type OwnProps = { export default function ProcessInstanceListSaveAsReport({ onSuccess, - columns, + columnArray, orderBy, filterBy, - buttonText = 'Save as New Perspective', + buttonText = 'Save as Perspective', }: OwnProps) { const [identifier, setIdentifier] = useState(''); @@ -33,9 +33,8 @@ export default function ProcessInstanceListSaveAsReport({ const addProcessInstanceReport = (event: any) => { event.preventDefault(); - const columnArray = columns.split(',').map((column) => { - return { Header: column, accessor: column }; - }); + console.log(columnArray); + const orderByArray = orderBy.split(',').filter((n) => n); const filterByArray = filterBy diff --git a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx index 769bfea7..fcbe45ad 100644 --- a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx +++ b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx @@ -622,6 +622,10 @@ export default function ProcessInstanceListTable({ ); }; + const reportColumns = () => { + return (reportMetadata as any).columns; + }; + const buildTable = () => { const headerLabels: Record = { id: 'Id', @@ -636,7 +640,7 @@ export default function ProcessInstanceListTable({ const getHeaderLabel = (header: string) => { return headerLabels[header] ?? header; }; - const headers = (reportMetadata as any).columns.map((column: any) => { + const headers = reportColumns().map((column: any) => { // return {getHeaderLabel((column as any).Header)}; return getHeaderLabel((column as any).Header); }); @@ -710,7 +714,7 @@ export default function ProcessInstanceListTable({ }; const rows = processInstances.map((row: any) => { - const currentRow = (reportMetadata as any).columns.map((column: any) => { + const currentRow = reportColumns().map((column: any) => { return formattedColumn(row, column); }); return {currentRow}; @@ -766,11 +770,12 @@ export default function ProcessInstanceListTable({ }; const saveAsReportComponent = () => { + // TODO onSuccess reload/select the new report const callback = (_: any) => {}; return (