added new page to create process models using english text w/ burnettk
This commit is contained in:
parent
00c373c88a
commit
73b51d76d4
|
@ -396,6 +396,7 @@ def process_instance_report_update(
|
||||||
report_id: int,
|
report_id: int,
|
||||||
body: Dict[str, Any],
|
body: Dict[str, Any],
|
||||||
) -> flask.wrappers.Response:
|
) -> flask.wrappers.Response:
|
||||||
|
"""Process_instance_report_update."""
|
||||||
process_instance_report = ProcessInstanceReportModel.query.filter_by(
|
process_instance_report = ProcessInstanceReportModel.query.filter_by(
|
||||||
id=report_id,
|
id=report_id,
|
||||||
created_by_id=g.user.id,
|
created_by_id=g.user.id,
|
||||||
|
@ -416,6 +417,7 @@ def process_instance_report_update(
|
||||||
def process_instance_report_delete(
|
def process_instance_report_delete(
|
||||||
report_id: int,
|
report_id: int,
|
||||||
) -> flask.wrappers.Response:
|
) -> flask.wrappers.Response:
|
||||||
|
"""Process_instance_report_delete."""
|
||||||
process_instance_report = ProcessInstanceReportModel.query.filter_by(
|
process_instance_report = ProcessInstanceReportModel.query.filter_by(
|
||||||
id=report_id,
|
id=report_id,
|
||||||
created_by_id=g.user.id,
|
created_by_id=g.user.id,
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from spiffworkflow_backend.models.process_instance_report import ProcessInstanceReportModel
|
from spiffworkflow_backend.models.process_instance_report import ProcessInstanceReportModel
|
||||||
from spiffworkflow_backend.services.file_system_service import FileSystemService
|
|
||||||
import re
|
import re
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
@ -366,16 +365,17 @@ def process_model_create_with_natural_language(
|
||||||
)
|
)
|
||||||
|
|
||||||
ProcessModelService.add_process_model(process_model_info)
|
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 = ''
|
bpmn_template_contents = ''
|
||||||
with open(bpmn_template_file, encoding="utf-8") as f:
|
with open(bpmn_template_file, encoding="utf-8") as f:
|
||||||
bpmn_template_contents = f.read()
|
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(
|
||||||
bpmn_template_contents = bpmn_template_contents.replace('form-identifier-id-template-', form_identifier)
|
'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 = {
|
form_uischema_json: dict = {
|
||||||
"ui:order": []
|
"ui:order": columns
|
||||||
}
|
}
|
||||||
|
|
||||||
form_properties: dict = {}
|
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"{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}-schema.json",
|
||||||
SpecFileService.add_file(process_model_info, f"{form_identifier}-uischema.json", str.encode(json.dumps(form_uischema_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(
|
_commit_and_push_to_git(
|
||||||
f"User: {g.user.username} created process model via natural language:"
|
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')
|
default_report_metadata = ProcessInstanceReportService.system_metadata_map('default')
|
||||||
for column in columns:
|
for column in columns:
|
||||||
default_report_metadata['columns'].append({
|
default_report_metadata['columns'].append({
|
||||||
"Header": column, "accessor": column
|
"Header": column, "accessor": column, "filterable": True
|
||||||
})
|
})
|
||||||
ProcessInstanceReportModel.create_report(
|
ProcessInstanceReportModel.create_report(
|
||||||
identifier=process_model_identifier,
|
identifier=process_model_identifier,
|
||||||
|
|
|
@ -86,6 +86,7 @@ class ProcessInstanceReportService:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def system_metadata_map(cls, metadata_key: str) -> dict[str, Any]:
|
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)
|
# TODO replace with system reports that are loaded on launch (or similar)
|
||||||
temp_system_metadata_map = {
|
temp_system_metadata_map = {
|
||||||
"default": {
|
"default": {
|
||||||
|
|
|
@ -221,7 +221,8 @@ class TestProcessApi(BaseTest):
|
||||||
process_instance_report = ProcessInstanceReportModel.query.filter_by(identifier='bug-tracker').first()
|
process_instance_report = ProcessInstanceReportModel.query.filter_by(identifier='bug-tracker').first()
|
||||||
assert process_instance_report is not None
|
assert process_instance_report is not None
|
||||||
report_column_accessors = [i['accessor'] for i in process_instance_report.report_metadata['columns']]
|
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
|
assert report_column_accessors == expected_column_accessors
|
||||||
|
|
||||||
def test_primary_process_id_updates_via_xml(
|
def test_primary_process_id_updates_via_xml(
|
||||||
|
|
|
@ -22,6 +22,7 @@ import ProcessInstanceLogList from './ProcessInstanceLogList';
|
||||||
import MessageInstanceList from './MessageInstanceList';
|
import MessageInstanceList from './MessageInstanceList';
|
||||||
import Configuration from './Configuration';
|
import Configuration from './Configuration';
|
||||||
import JsonSchemaFormBuilder from './JsonSchemaFormBuilder';
|
import JsonSchemaFormBuilder from './JsonSchemaFormBuilder';
|
||||||
|
import ProcessModelNewExperimental from './ProcessModelNewExperimental';
|
||||||
|
|
||||||
export default function AdminRoutes() {
|
export default function AdminRoutes() {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
@ -50,6 +51,10 @@ export default function AdminRoutes() {
|
||||||
path="process-models/:process_group_id/new"
|
path="process-models/:process_group_id/new"
|
||||||
element={<ProcessModelNew />}
|
element={<ProcessModelNew />}
|
||||||
/>
|
/>
|
||||||
|
<Route
|
||||||
|
path="process-models/:process_group_id/new-e"
|
||||||
|
element={<ProcessModelNewExperimental />}
|
||||||
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="process-models/:process_model_id"
|
path="process-models/:process_model_id"
|
||||||
element={<ProcessModelShow />}
|
element={<ProcessModelShow />}
|
||||||
|
|
|
@ -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>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in New Issue