From fa85a06efef976ca2b0af253012ca6a179fd0083 Mon Sep 17 00:00:00 2001 From: jasquat Date: Thu, 4 May 2023 08:00:37 -0400 Subject: [PATCH] allow adding waiting_for and task_title columns in instance list page --- .../routes/process_instances_controller.py | 4 ++-- .../services/process_instance_report_service.py | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py index fa8f62de1..e7dfa206c 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py @@ -298,8 +298,8 @@ def process_instance_report_show( def process_instance_report_column_list( process_model_identifier: Optional[str] = None, ) -> flask.wrappers.Response: - """Process_instance_report_column_list.""" table_columns = ProcessInstanceReportService.builtin_column_options() + system_report_column_options = ProcessInstanceReportService.system_report_column_options() columns_for_metadata_query = ( db.session.query(ProcessInstanceMetadataModel.key) .order_by(ProcessInstanceMetadataModel.key) @@ -315,7 +315,7 @@ def process_instance_report_column_list( columns_for_metadata_strings = [ {"Header": i[0], "accessor": i[0], "filterable": True} for i in columns_for_metadata ] - return make_response(jsonify(table_columns + columns_for_metadata_strings), 200) + return make_response(jsonify(table_columns + system_report_column_options + columns_for_metadata_strings), 200) def process_instance_show_for_me( 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 57af17eae..89417e637 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 @@ -320,7 +320,7 @@ class ProcessInstanceReportService: @classmethod def builtin_column_options(cls) -> list[ReportMetadataColumn]: - """Builtin_column_options.""" + """Columns that are actually in the process instance table.""" return_value: list[ReportMetadataColumn] = [ {"Header": "Id", "accessor": "id", "filterable": False}, { @@ -339,6 +339,15 @@ class ProcessInstanceReportService: ] return return_value + @classmethod + def system_report_column_options(cls) -> list[ReportMetadataColumn]: + """Columns that are used with certain system reports.""" + return_value: list[ReportMetadataColumn] = [ + {"Header": "Task", "accessor": "task_title", "filterable": False}, + {"Header": "Waiting For", "accessor": "waiting_for", "filterable": False}, + ] + return return_value + @classmethod def get_filter_value(cls, filters: list[FilterValue], filter_key: str) -> Any: for filter in filters: