This commit is contained in:
Jon Herron 2022-11-28 13:56:45 -05:00
parent 77f628426a
commit 0fb14f0e57
2 changed files with 13 additions and 9 deletions

View File

@ -11,7 +11,7 @@ import HttpService from '../services/HttpService';
type OwnProps = { type OwnProps = {
onSuccess: (..._args: any[]) => any; onSuccess: (..._args: any[]) => any;
columns: string; columnArray: { Header: string; accessor: string};
orderBy: string; orderBy: string;
filterBy: string; filterBy: string;
buttonText?: string; buttonText?: string;
@ -19,10 +19,10 @@ type OwnProps = {
export default function ProcessInstanceListSaveAsReport({ export default function ProcessInstanceListSaveAsReport({
onSuccess, onSuccess,
columns, columnArray,
orderBy, orderBy,
filterBy, filterBy,
buttonText = 'Save as New Perspective', buttonText = 'Save as Perspective',
}: OwnProps) { }: OwnProps) {
const [identifier, setIdentifier] = useState(''); const [identifier, setIdentifier] = useState('');
@ -33,9 +33,8 @@ export default function ProcessInstanceListSaveAsReport({
const addProcessInstanceReport = (event: any) => { const addProcessInstanceReport = (event: any) => {
event.preventDefault(); event.preventDefault();
const columnArray = columns.split(',').map((column) => { console.log(columnArray);
return { Header: column, accessor: column };
});
const orderByArray = orderBy.split(',').filter((n) => n); const orderByArray = orderBy.split(',').filter((n) => n);
const filterByArray = filterBy const filterByArray = filterBy

View File

@ -622,6 +622,10 @@ export default function ProcessInstanceListTable({
); );
}; };
const reportColumns = () => {
return (reportMetadata as any).columns;
};
const buildTable = () => { const buildTable = () => {
const headerLabels: Record<string, string> = { const headerLabels: Record<string, string> = {
id: 'Id', id: 'Id',
@ -636,7 +640,7 @@ export default function ProcessInstanceListTable({
const getHeaderLabel = (header: string) => { const getHeaderLabel = (header: string) => {
return headerLabels[header] ?? header; return headerLabels[header] ?? header;
}; };
const headers = (reportMetadata as any).columns.map((column: any) => { const headers = reportColumns().map((column: any) => {
// return <th>{getHeaderLabel((column as any).Header)}</th>; // return <th>{getHeaderLabel((column as any).Header)}</th>;
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 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 formattedColumn(row, column);
}); });
return <tr key={row.id}>{currentRow}</tr>; return <tr key={row.id}>{currentRow}</tr>;
@ -766,11 +770,12 @@ export default function ProcessInstanceListTable({
}; };
const saveAsReportComponent = () => { const saveAsReportComponent = () => {
// TODO onSuccess reload/select the new report
const callback = (_: any) => {}; const callback = (_: any) => {};
return ( return (
<ProcessInstanceListSaveAsReport <ProcessInstanceListSaveAsReport
onSuccess={callback} onSuccess={callback}
columns="" columnArray={reportColumns()}
orderBy="" orderBy=""
filterBy="" filterBy=""
/> />