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 c1c4c1b0b..3f7da50c9 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py @@ -396,6 +396,7 @@ def process_instance_report_update( report_id: int, body: Dict[str, Any], ) -> flask.wrappers.Response: + """Process_instance_report_update.""" process_instance_report = ProcessInstanceReportModel.query.filter_by( id=report_id, created_by_id=g.user.id, @@ -416,6 +417,7 @@ def process_instance_report_update( def process_instance_report_delete( report_id: int, ) -> flask.wrappers.Response: + """Process_instance_report_delete.""" process_instance_report = ProcessInstanceReportModel.query.filter_by( id=report_id, created_by_id=g.user.id, diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_models_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_models_controller.py index 3c3a7382d..467062bec 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_models_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_models_controller.py @@ -2,7 +2,6 @@ import json import os from spiffworkflow_backend.models.process_instance_report import ProcessInstanceReportModel -from spiffworkflow_backend.services.file_system_service import FileSystemService import re from typing import Any from typing import Dict @@ -366,16 +365,17 @@ def process_model_create_with_natural_language( ) ProcessModelService.add_process_model(process_model_info) - bpmn_process_identifier = f"{process_model_info.id}_process" + bpmn_process_identifier = f"{process_model_identifier}_process" bpmn_template_contents = '' with open(bpmn_template_file, encoding="utf-8") as f: bpmn_template_contents = f.read() - bpmn_template_contents = bpmn_template_contents.replace('natural_language_process_id_template', bpmn_process_identifier) - bpmn_template_contents = bpmn_template_contents.replace('form-identifier-id-template-', form_identifier) + bpmn_template_contents = bpmn_template_contents.replace( + 'natural_language_process_id_template', bpmn_process_identifier) + bpmn_template_contents = bpmn_template_contents.replace('form-identifier-id-template', form_identifier) form_uischema_json: dict = { - "ui:order": [] + "ui:order": columns } form_properties: dict = {} @@ -392,8 +392,10 @@ def process_model_create_with_natural_language( } SpecFileService.add_file(process_model_info, f"{process_model_identifier}.bpmn", str.encode(bpmn_template_contents)) - SpecFileService.add_file(process_model_info, f"{form_identifier}-schema.json", str.encode(json.dumps(form_schema_json))) - SpecFileService.add_file(process_model_info, f"{form_identifier}-uischema.json", str.encode(json.dumps(form_uischema_json))) + SpecFileService.add_file(process_model_info, f"{form_identifier}-schema.json", + str.encode(json.dumps(form_schema_json))) + SpecFileService.add_file( + process_model_info, f"{form_identifier}-uischema.json", str.encode(json.dumps(form_uischema_json))) _commit_and_push_to_git( f"User: {g.user.username} created process model via natural language:" @@ -403,7 +405,7 @@ def process_model_create_with_natural_language( default_report_metadata = ProcessInstanceReportService.system_metadata_map('default') for column in columns: default_report_metadata['columns'].append({ - "Header": column, "accessor": column + "Header": column, "accessor": column, "filterable": True }) ProcessInstanceReportModel.create_report( identifier=process_model_identifier, 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 2ae12769c..cd72ccfa8 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 @@ -86,6 +86,7 @@ class ProcessInstanceReportService: @classmethod def system_metadata_map(cls, metadata_key: str) -> dict[str, Any]: + """System_metadata_map.""" # TODO replace with system reports that are loaded on launch (or similar) temp_system_metadata_map = { "default": { diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py index 7096499e4..d058f9013 100644 --- a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py @@ -221,7 +221,8 @@ class TestProcessApi(BaseTest): process_instance_report = ProcessInstanceReportModel.query.filter_by(identifier='bug-tracker').first() assert process_instance_report is not None report_column_accessors = [i['accessor'] for i in process_instance_report.report_metadata['columns']] - expected_column_accessors = ['id', 'process_model_display_name', 'start_in_seconds', 'end_in_seconds', 'username', 'status', 'summary', 'description', 'priority'] + expected_column_accessors = ['id', 'process_model_display_name', 'start_in_seconds', + 'end_in_seconds', 'username', 'status', 'summary', 'description', 'priority'] assert report_column_accessors == expected_column_accessors def test_primary_process_id_updates_via_xml( diff --git a/spiffworkflow-frontend/src/routes/AdminRoutes.tsx b/spiffworkflow-frontend/src/routes/AdminRoutes.tsx index cc120c51a..2d61439bf 100644 --- a/spiffworkflow-frontend/src/routes/AdminRoutes.tsx +++ b/spiffworkflow-frontend/src/routes/AdminRoutes.tsx @@ -22,6 +22,7 @@ import ProcessInstanceLogList from './ProcessInstanceLogList'; import MessageInstanceList from './MessageInstanceList'; import Configuration from './Configuration'; import JsonSchemaFormBuilder from './JsonSchemaFormBuilder'; +import ProcessModelNewExperimental from './ProcessModelNewExperimental'; export default function AdminRoutes() { const location = useLocation(); @@ -50,6 +51,10 @@ export default function AdminRoutes() { path="process-models/:process_group_id/new" element={} /> + } + /> } diff --git a/spiffworkflow-frontend/src/routes/ProcessModelNewExperimental.tsx b/spiffworkflow-frontend/src/routes/ProcessModelNewExperimental.tsx new file mode 100644 index 000000000..af8be8226 --- /dev/null +++ b/spiffworkflow-frontend/src/routes/ProcessModelNewExperimental.tsx @@ -0,0 +1,73 @@ +import { useState } from 'react'; +import { useNavigate, useParams } from 'react-router-dom'; +// @ts-ignore +import { TextArea, Button, Form } from '@carbon/react'; +import ProcessBreadcrumb from '../components/ProcessBreadcrumb'; +import { ProcessModel } from '../interfaces'; +import { modifyProcessIdentifierForPathParam } from '../helpers'; +import HttpService from '../services/HttpService'; + +export default function ProcessModelNewExperimental() { + const params = useParams(); + const navigate = useNavigate(); + const [processModelDescriptiveText, setProcessModelDescriptiveText] = + useState(''); + + const helperText = + 'Create a bug tracker process model with a bug-details form that collects summary, description, and priority'; + + const navigateToProcessModel = (result: ProcessModel) => { + if ('id' in result) { + const modifiedProcessModelPathFromResult = + modifyProcessIdentifierForPathParam(result.id); + navigate(`/admin/process-models/${modifiedProcessModelPathFromResult}`); + } + }; + + const handleFormSubmission = (event: any) => { + event.preventDefault(); + HttpService.makeCallToBackend({ + path: `/process-models-natural-language/${params.process_group_id}`, + successCallback: navigateToProcessModel, + httpMethod: 'POST', + postBody: { natural_language_text: processModelDescriptiveText }, + }); + }; + + const ohYeeeeaah = () => { + setProcessModelDescriptiveText(helperText); + }; + + return ( + <> + + {/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */} +

+ Add Process Model +

+
+