From 95be02965638825d485f3610faaad3dbef44ef36 Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 12 Dec 2022 13:41:42 -0500 Subject: [PATCH] split out completed instances by group as well --- .../src/spiffworkflow_backend/api.yml | 6 +++ .../routes/process_api_blueprint.py | 15 ++++-- .../components/ProcessInstanceListTable.tsx | 7 +++ .../src/components/TasksTable.tsx | 2 +- .../components/TasksWaitingForMyGroups.tsx | 1 + .../src/routes/CompletedInstances.tsx | 53 ++++++++++++++----- 6 files changed, 66 insertions(+), 18 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/api.yml b/spiffworkflow-backend/src/spiffworkflow_backend/api.yml index d6066093..d14a514b 100755 --- a/spiffworkflow-backend/src/spiffworkflow_backend/api.yml +++ b/spiffworkflow-backend/src/spiffworkflow_backend/api.yml @@ -595,6 +595,12 @@ paths: description: Specifies the identifier of a report to use, if any schema: type: integer + - name: group_identifier + in: query + required: false + description: The identifier of the group to get the process instances for + schema: + type: string get: operationId: spiffworkflow_backend.routes.process_api_blueprint.process_instance_list summary: Returns a list of process instances for a given process model diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py index 19f38934..895f8e1b 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py @@ -821,6 +821,7 @@ def process_instance_list( user_filter: Optional[bool] = False, report_identifier: Optional[str] = None, report_id: Optional[int] = None, + group_identifier: Optional[str] = None, ) -> flask.wrappers.Response: """Process_instance_list.""" process_instance_report = ProcessInstanceReportService.report_with_identifier( @@ -960,10 +961,16 @@ def process_instance_list( process_instance_query = process_instance_query.filter( SpiffLoggingModel.spiff_step == SpiffStepDetailsModel.spiff_step ) - process_instance_query = process_instance_query.join( - GroupModel, - GroupModel.id == SpiffStepDetailsModel.lane_assignment_id, - ) + if (group_identifier): + process_instance_query = process_instance_query.join( + GroupModel, + GroupModel.identifier == group_identifier, + ) + else: + process_instance_query = process_instance_query.join( + GroupModel, + GroupModel.id == SpiffStepDetailsModel.lane_assignment_id, + ) process_instance_query = process_instance_query.join( UserGroupAssignmentModel, UserGroupAssignmentModel.group_id == GroupModel.id, diff --git a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx index 98b76df3..5e62fcf0 100644 --- a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx +++ b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx @@ -79,6 +79,7 @@ type OwnProps = { textToShowIfEmpty?: string; paginationClassName?: string; autoReload?: boolean; + additionalParams?: string; }; interface dateParameters { @@ -90,6 +91,7 @@ export default function ProcessInstanceListTable({ processModelFullIdentifier, paginationQueryParamPrefix, perPageOptions, + additionalParams, showReports = true, reportIdentifier, textToShowIfEmpty, @@ -253,6 +255,10 @@ export default function ProcessInstanceListTable({ } ); + if (additionalParams) { + queryParamString += `&${additionalParams}`; + } + HttpService.makeCallToBackend({ path: `/process-instances?${queryParamString}`, successCallback: setProcessInstancesFromResult, @@ -315,6 +321,7 @@ export default function ProcessInstanceListTable({ processModelFullIdentifier, perPageOptions, reportIdentifier, + additionalParams, ]); // This sets the filter data using the saved reports returned from the initial instance_list query. diff --git a/spiffworkflow-frontend/src/components/TasksTable.tsx b/spiffworkflow-frontend/src/components/TasksTable.tsx index 1c4d15e9..0c657016 100644 --- a/spiffworkflow-frontend/src/components/TasksTable.tsx +++ b/spiffworkflow-frontend/src/components/TasksTable.tsx @@ -58,7 +58,7 @@ export default function TasksTable({ }; let params = `?per_page=${perPage}&page=${page}`; if (additionalParams) { - params = `${params}&${additionalParams}`; + params += `&${additionalParams}`; } HttpService.makeCallToBackend({ path: `${apiPath}${params}`, diff --git a/spiffworkflow-frontend/src/components/TasksWaitingForMyGroups.tsx b/spiffworkflow-frontend/src/components/TasksWaitingForMyGroups.tsx index 99616447..948aee6c 100644 --- a/spiffworkflow-frontend/src/components/TasksWaitingForMyGroups.tsx +++ b/spiffworkflow-frontend/src/components/TasksWaitingForMyGroups.tsx @@ -11,6 +11,7 @@ export default function TasksWaitingForMyGroups() { successCallback: setUserGroups, }); }, [setUserGroups]); + const tableComponents = () => { if (!userGroups) { return null; diff --git a/spiffworkflow-frontend/src/routes/CompletedInstances.tsx b/spiffworkflow-frontend/src/routes/CompletedInstances.tsx index f97bb5d5..4583d027 100644 --- a/spiffworkflow-frontend/src/routes/CompletedInstances.tsx +++ b/spiffworkflow-frontend/src/routes/CompletedInstances.tsx @@ -1,6 +1,45 @@ +import { useEffect, useState } from 'react'; import ProcessInstanceListTable from '../components/ProcessInstanceListTable'; +import HttpService from '../services/HttpService'; export default function CompletedInstances() { + const [userGroups, setUserGroups] = useState(null); + + useEffect(() => { + HttpService.makeCallToBackend({ + path: `/user-groups/for-current-user`, + successCallback: setUserGroups, + }); + }, [setUserGroups]); + + const groupTableComponents = () => { + if (!userGroups) { + return null; + } + + return userGroups.map((userGroup: string) => { + return ( + <> +

Tasks completed by {userGroup} group

+

+ This is a list of instances with tasks that were completed by the{' '} + {userGroup} group. +

+ + + ); + }); + }; + return ( <>

My completed instances

@@ -30,19 +69,7 @@ export default function CompletedInstances() { textToShowIfEmpty="You have no completed tasks at this time." paginationClassName="with-large-bottom-margin" /> -

Tasks completed by my groups

-

- This is a list of instances with tasks that were completed by groups you - belong to. -

- + {groupTableComponents()} ); }