From a081c9a93cccc3ca9ce8f824e6d31a2a019f61c6 Mon Sep 17 00:00:00 2001 From: Jon Herron Date: Mon, 28 Nov 2022 14:14:35 -0500 Subject: [PATCH] Save selected process model --- .../ProcessInstanceListSaveAsReport.tsx | 29 +++++++------------ .../components/ProcessInstanceListTable.tsx | 2 +- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/spiffworkflow-frontend/src/components/ProcessInstanceListSaveAsReport.tsx b/spiffworkflow-frontend/src/components/ProcessInstanceListSaveAsReport.tsx index b1187e9ed..35cb92236 100644 --- a/spiffworkflow-frontend/src/components/ProcessInstanceListSaveAsReport.tsx +++ b/spiffworkflow-frontend/src/components/ProcessInstanceListSaveAsReport.tsx @@ -7,13 +7,14 @@ import { // @ts-ignore } from '@carbon/react'; */ +import { ProcessModel } from '../interfaces'; import HttpService from '../services/HttpService'; type OwnProps = { onSuccess: (..._args: any[]) => any; columnArray: { Header: string; accessor: string }; orderBy: string; - filterBy: string; + processModelSelection: ProcessModel | null; buttonText?: string; }; @@ -21,7 +22,7 @@ export default function ProcessInstanceListSaveAsReport({ onSuccess, columnArray, orderBy, - filterBy, + processModelSelection, buttonText = 'Save as Perspective', }: OwnProps) { const [identifier, setIdentifier] = useState(''); @@ -33,24 +34,16 @@ export default function ProcessInstanceListSaveAsReport({ const addProcessInstanceReport = (event: any) => { event.preventDefault(); - console.log(columnArray); - const orderByArray = orderBy.split(',').filter((n) => n); - const filterByArray = filterBy - .split(',') - .map((filterByItem) => { - const [fieldName, fieldValue] = filterByItem.split('='); - if (fieldValue) { - return { - field_name: fieldName, - operator: 'equals', - field_value: fieldValue, - }; - } - return null; - }) - .filter((n) => n); + const filterByArray: any = []; + + if (processModelSelection) { + filterByArray.push({ + field_name: 'process_model_identifier', + field_value: processModelSelection.id, + }); + } HttpService.makeCallToBackend({ path: `/process-instances/reports`, diff --git a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx index e98b5978f..46bdae476 100644 --- a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx +++ b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx @@ -777,7 +777,7 @@ export default function ProcessInstanceListTable({ onSuccess={callback} columnArray={reportColumns()} orderBy="" - filterBy="" + processModelSelection={processModelSelection} /> ); };