added new page to create process models using english text w/ burnettk

This commit is contained in:
jasquat 2023-01-03 17:26:01 -05:00
parent df462e0dd0
commit 2c4ae424a4
6 changed files with 93 additions and 9 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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": {

View File

@ -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(

View File

@ -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={<ProcessModelNew />}
/>
<Route
path="process-models/:process_group_id/new-e"
element={<ProcessModelNewExperimental />}
/>
<Route
path="process-models/:process_model_id"
element={<ProcessModelShow />}

View File

@ -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<string>('');
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 (
<>
<ProcessBreadcrumb
hotCrumbs={[
['Process Groups', '/admin'],
{
entityToExplode: params.process_group_id || '',
entityType: 'process-group-id',
linkLastItem: true,
},
]}
/>
{/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */}
<h1 title={helperText} onClick={ohYeeeeaah} onKeyDown={ohYeeeeaah}>
Add Process Model
</h1>
<Form onSubmit={handleFormSubmission}>
<TextArea
id="process-model-descriptive-text"
value={processModelDescriptiveText}
labelText="Process Model Descriptive Text"
placeholder="your text"
onChange={(event: any) =>
setProcessModelDescriptiveText(event.target.value)
}
/>
<Button kind="secondary" type="submit">
Submit
</Button>
</Form>
</>
);
}