From b179b66e2619ff2d255a847d89eb548d853f072a Mon Sep 17 00:00:00 2001 From: jasquat Date: Fri, 28 Apr 2023 12:36:16 -0400 Subject: [PATCH] home page tables are working again w/ burnettk --- .../process_instance_report_service.py | 2 +- .../ProcessInstanceListSaveAsReport.tsx | 2 +- .../components/ProcessInstanceListTable.tsx | 33 +++++++++++-------- .../src/routes/CompletedInstances.tsx | 4 ++- .../src/routes/InProgressInstances.tsx | 4 ++- 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_report_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_report_service.py index a95cec34..dee7ea09 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_report_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_report_service.py @@ -527,7 +527,7 @@ class ProcessInstanceReportService: results = cls.add_metadata_columns_to_process_instance(process_instances.items, report_metadata["columns"]) for value in cls.check_filter_value(filters, "oldest_open_human_task_fields"): - results = cls.add_human_task_fields(results, value) + results = cls.add_human_task_fields(results, value.split(",")) response_json = { "report_metadata": report_metadata, "results": results, diff --git a/spiffworkflow-frontend/src/components/ProcessInstanceListSaveAsReport.tsx b/spiffworkflow-frontend/src/components/ProcessInstanceListSaveAsReport.tsx index 9f912628..6e43b212 100644 --- a/spiffworkflow-frontend/src/components/ProcessInstanceListSaveAsReport.tsx +++ b/spiffworkflow-frontend/src/components/ProcessInstanceListSaveAsReport.tsx @@ -6,7 +6,7 @@ import { Modal, // @ts-ignore } from '@carbon/react'; -import { ProcessInstanceReport, ReportMetadata } from '../interfaces'; +import { ProcessInstanceReport } from '../interfaces'; import HttpService from '../services/HttpService'; type OwnProps = { diff --git a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx index 1bb76de9..4430a500 100644 --- a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx +++ b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx @@ -87,7 +87,7 @@ type OwnProps = { textToShowIfEmpty?: string; paginationClassName?: string; autoReload?: boolean; - additionalParams?: string; + additionalReportFilters?: ReportFilter[]; variant?: string; canCompleteAllTasks?: boolean; showActionsColumn?: boolean; @@ -102,7 +102,7 @@ export default function ProcessInstanceListTable({ processModelFullIdentifier, paginationQueryParamPrefix, perPageOptions, - additionalParams, + additionalReportFilters, showReports = true, reportIdentifier, textToShowIfEmpty, @@ -330,6 +330,9 @@ export default function ProcessInstanceListTable({ } } + // this is the code to re-populate the widgets on the page + // with values from the report metadata, which is derived + // from the searchParams (often report_hash) let selectedProcessModelIdentifier = processModelFullIdentifier; reportMetadataBodyToUse.filter_by.forEach( (reportFilter: ReportFilter) => { @@ -360,7 +363,6 @@ export default function ProcessInstanceListTable({ } } ); - processModelSelectionItemsForUseEffect.forEach( (processModel: ProcessModel) => { if (processModel.id === selectedProcessModelIdentifier) { @@ -384,9 +386,13 @@ export default function ProcessInstanceListTable({ // eslint-disable-next-line prefer-destructuring perPage = perPageOptions[1]; } - let queryParamString = `per_page=${perPage}&page=${page}`; - if (additionalParams) { - queryParamString += `&${additionalParams}`; + const queryParamString = `per_page=${perPage}&page=${page}`; + if (additionalReportFilters) { + additionalReportFilters.forEach((arf: ReportFilter) => { + if (!reportMetadataBodyToUse.filter_by.includes(arf)) { + reportMetadataBodyToUse.filter_by.push(arf); + } + }); } HttpService.makeCallToBackend({ @@ -405,13 +411,14 @@ export default function ProcessInstanceListTable({ return; } const queryParams: string[] = []; - ['report_hash', 'report_id', 'report_identifier'].forEach( - (paramName: string) => { - if (searchParams.get(paramName)) { - queryParams.push(`${paramName}=${searchParams.get(paramName)}`); - } + ['report_hash', 'report_id'].forEach((paramName: string) => { + if (searchParams.get(paramName)) { + queryParams.push(`${paramName}=${searchParams.get(paramName)}`); } - ); + }); + if (reportIdentifier) { + queryParams.push(`report_identifier=${reportIdentifier}`); + } if (queryParams.length > 0) { const queryParamString = `?${queryParams.join('&')}`; @@ -476,7 +483,7 @@ export default function ProcessInstanceListTable({ processModelFullIdentifier, perPageOptions, reportIdentifier, - additionalParams, + additionalReportFilters, processInstanceApiSearchPath, permissionsLoaded, listHasBeenFiltered, diff --git a/spiffworkflow-frontend/src/routes/CompletedInstances.tsx b/spiffworkflow-frontend/src/routes/CompletedInstances.tsx index 6d43020d..581dbe04 100644 --- a/spiffworkflow-frontend/src/routes/CompletedInstances.tsx +++ b/spiffworkflow-frontend/src/routes/CompletedInstances.tsx @@ -32,7 +32,9 @@ export default function CompletedInstances() { reportIdentifier="system_report_completed_instances_with_tasks_completed_by_my_groups" showReports={false} textToShowIfEmpty="This group has no completed instances at this time." - additionalParams={`user_group_identifier=${userGroup}`} + additionalReportFilters={[ + { field_name: 'user_group_identifier', field_value: userGroup }, + ]} showActionsColumn /> diff --git a/spiffworkflow-frontend/src/routes/InProgressInstances.tsx b/spiffworkflow-frontend/src/routes/InProgressInstances.tsx index 9ba7cd26..1943e67d 100644 --- a/spiffworkflow-frontend/src/routes/InProgressInstances.tsx +++ b/spiffworkflow-frontend/src/routes/InProgressInstances.tsx @@ -35,7 +35,9 @@ export default function InProgressInstances() { reportIdentifier="system_report_in_progress_instances_with_tasks_for_my_group" showReports={false} textToShowIfEmpty="This group has no instances waiting on it at this time." - additionalParams={`user_group_identifier=${userGroup}`} + additionalReportFilters={[ + { field_name: 'user_group_identifier', field_value: userGroup }, + ]} canCompleteAllTasks showActionsColumn autoReload