make js Task interface act more like ProcessInstanceTask w/ burnettk
This commit is contained in:
parent
be201970ff
commit
02e0e95a06
|
@ -84,6 +84,7 @@ class TaskModel(SpiffworkflowBaseDBModel):
|
||||||
type: Optional[str] = None
|
type: Optional[str] = None
|
||||||
can_complete: Optional[bool] = None
|
can_complete: Optional[bool] = None
|
||||||
extensions: Optional[dict] = None
|
extensions: Optional[dict] = None
|
||||||
|
name_for_display: Optional[str] = None
|
||||||
|
|
||||||
def get_data(self) -> dict:
|
def get_data(self) -> dict:
|
||||||
return {**self.python_env_data(), **self.json_data()}
|
return {**self.python_env_data(), **self.json_data()}
|
||||||
|
|
|
@ -312,6 +312,7 @@ def task_show(process_instance_id: int, task_guid: str = "next") -> flask.wrappe
|
||||||
task_model.type = task_definition.typename
|
task_model.type = task_definition.typename
|
||||||
task_model.can_complete = can_complete
|
task_model.can_complete = can_complete
|
||||||
task_process_identifier = task_model.bpmn_process.bpmn_process_definition.bpmn_identifier
|
task_process_identifier = task_model.bpmn_process.bpmn_process_definition.bpmn_identifier
|
||||||
|
task_model.name_for_display = TaskService.get_name_for_display(task_definition)
|
||||||
|
|
||||||
process_model_with_form = process_model
|
process_model_with_form = process_model
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ export interface EventDefinition {
|
||||||
export interface Task {
|
export interface Task {
|
||||||
id: number;
|
id: number;
|
||||||
guid: string;
|
guid: string;
|
||||||
|
process_instance_id: number;
|
||||||
bpmn_identifier: string;
|
bpmn_identifier: string;
|
||||||
bpmn_name?: string;
|
bpmn_name?: string;
|
||||||
bpmn_process_direct_parent_guid: string;
|
bpmn_process_direct_parent_guid: string;
|
||||||
|
@ -52,6 +53,13 @@ export interface Task {
|
||||||
task_definition_properties_json: TaskDefinitionPropertiesJson;
|
task_definition_properties_json: TaskDefinitionPropertiesJson;
|
||||||
|
|
||||||
event_definition?: EventDefinition;
|
event_definition?: EventDefinition;
|
||||||
|
|
||||||
|
process_model_display_name: string;
|
||||||
|
process_model_identifier: string;
|
||||||
|
name_for_display: string;
|
||||||
|
can_complete: boolean;
|
||||||
|
form_schema: any;
|
||||||
|
form_ui_schema: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProcessInstanceTask {
|
export interface ProcessInstanceTask {
|
||||||
|
|
|
@ -18,7 +18,7 @@ import Form from '../themes/carbon';
|
||||||
import HttpService from '../services/HttpService';
|
import HttpService from '../services/HttpService';
|
||||||
import useAPIError from '../hooks/UseApiError';
|
import useAPIError from '../hooks/UseApiError';
|
||||||
import { modifyProcessIdentifierForPathParam } from '../helpers';
|
import { modifyProcessIdentifierForPathParam } from '../helpers';
|
||||||
import { ProcessInstanceTask } from '../interfaces';
|
import { Task } from '../interfaces';
|
||||||
import ProcessBreadcrumb from '../components/ProcessBreadcrumb';
|
import ProcessBreadcrumb from '../components/ProcessBreadcrumb';
|
||||||
import InstructionsForEndUser from '../components/InstructionsForEndUser';
|
import InstructionsForEndUser from '../components/InstructionsForEndUser';
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ enum FormSubmitType {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function TaskShow() {
|
export default function TaskShow() {
|
||||||
const [task, setTask] = useState<ProcessInstanceTask | null>(null);
|
const [task, setTask] = useState<Task | null>(null);
|
||||||
const [userTasks] = useState(null);
|
const [userTasks] = useState(null);
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
@ -105,7 +105,7 @@ export default function TaskShow() {
|
||||||
|
|
||||||
const { addError, removeError } = useAPIError();
|
const { addError, removeError } = useAPIError();
|
||||||
|
|
||||||
const navigateToInterstitial = (myTask: ProcessInstanceTask) => {
|
const navigateToInterstitial = (myTask: Task) => {
|
||||||
navigate(
|
navigate(
|
||||||
`/process/${modifyProcessIdentifierForPathParam(
|
`/process/${modifyProcessIdentifierForPathParam(
|
||||||
myTask.process_model_identifier
|
myTask.process_model_identifier
|
||||||
|
@ -114,7 +114,7 @@ export default function TaskShow() {
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const processResult = (result: ProcessInstanceTask) => {
|
const processResult = (result: Task) => {
|
||||||
setTask(result);
|
setTask(result);
|
||||||
setDisabled(false);
|
setDisabled(false);
|
||||||
if (!result.can_complete) {
|
if (!result.can_complete) {
|
||||||
|
@ -206,7 +206,7 @@ export default function TaskShow() {
|
||||||
const taskUrl = `/tasks/${params.process_instance_id}/${userTask.id}`;
|
const taskUrl = `/tasks/${params.process_instance_id}/${userTask.id}`;
|
||||||
if (userTask.id === params.task_id) {
|
if (userTask.id === params.task_id) {
|
||||||
selectedTabIndex = index;
|
selectedTabIndex = index;
|
||||||
return <Tab selected>{userTask.title}</Tab>;
|
return <Tab selected>{userTask.name_for_display}</Tab>;
|
||||||
}
|
}
|
||||||
if (userTask.state === 'COMPLETED') {
|
if (userTask.state === 'COMPLETED') {
|
||||||
return (
|
return (
|
||||||
|
@ -214,12 +214,12 @@ export default function TaskShow() {
|
||||||
onClick={() => navigate(taskUrl)}
|
onClick={() => navigate(taskUrl)}
|
||||||
data-qa={`form-nav-${userTask.name}`}
|
data-qa={`form-nav-${userTask.name}`}
|
||||||
>
|
>
|
||||||
{userTask.title}
|
{userTask.name_for_display}
|
||||||
</Tab>
|
</Tab>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (userTask.state === 'FUTURE') {
|
if (userTask.state === 'FUTURE') {
|
||||||
return <Tab disabled>{userTask.title}</Tab>;
|
return <Tab disabled>{userTask.name_for_display}</Tab>;
|
||||||
}
|
}
|
||||||
if (userTask.state === 'READY') {
|
if (userTask.state === 'READY') {
|
||||||
return (
|
return (
|
||||||
|
@ -227,7 +227,7 @@ export default function TaskShow() {
|
||||||
onClick={() => navigate(taskUrl)}
|
onClick={() => navigate(taskUrl)}
|
||||||
data-qa={`form-nav-${userTask.name}`}
|
data-qa={`form-nav-${userTask.name}`}
|
||||||
>
|
>
|
||||||
{userTask.title}
|
{userTask.name_for_display}
|
||||||
</Tab>
|
</Tab>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -297,7 +297,7 @@ export default function TaskShow() {
|
||||||
let taskData = task.data;
|
let taskData = task.data;
|
||||||
let jsonSchema = task.form_schema;
|
let jsonSchema = task.form_schema;
|
||||||
let reactFragmentToHideSubmitButton = null;
|
let reactFragmentToHideSubmitButton = null;
|
||||||
if (task.type === 'ManualTask') {
|
if (task.typename === 'ManualTask') {
|
||||||
taskData = {};
|
taskData = {};
|
||||||
jsonSchema = {
|
jsonSchema = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
|
@ -333,9 +333,9 @@ export default function TaskShow() {
|
||||||
if (task.state === 'READY') {
|
if (task.state === 'READY') {
|
||||||
let submitButtonText = 'Submit';
|
let submitButtonText = 'Submit';
|
||||||
let saveAsDraftButton = null;
|
let saveAsDraftButton = null;
|
||||||
if (task.type === 'ManualTask') {
|
if (task.typename === 'ManualTask') {
|
||||||
submitButtonText = 'Continue';
|
submitButtonText = 'Continue';
|
||||||
} else if (task.type === 'UserTask') {
|
} else if (task.typename === 'UserTask') {
|
||||||
saveAsDraftButton = (
|
saveAsDraftButton = (
|
||||||
<Button
|
<Button
|
||||||
id="save-as-draft-button"
|
id="save-as-draft-button"
|
||||||
|
@ -404,12 +404,13 @@ export default function TaskShow() {
|
||||||
task.process_model_identifier
|
task.process_model_identifier
|
||||||
)}/${params.process_instance_id}`,
|
)}/${params.process_instance_id}`,
|
||||||
],
|
],
|
||||||
[`Task: ${task.title || task.id}`],
|
[`Task: ${task.name_for_display || task.id}`],
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
<div>{buildTaskNavigation()}</div>
|
<div>{buildTaskNavigation()}</div>
|
||||||
<h3>
|
<h3>
|
||||||
Task: {task.title} ({task.process_model_display_name}){statusString}
|
Task: {task.name_for_display} ({task.process_model_display_name})
|
||||||
|
{statusString}
|
||||||
</h3>
|
</h3>
|
||||||
<InstructionsForEndUser task={task} />
|
<InstructionsForEndUser task={task} />
|
||||||
{formElement()}
|
{formElement()}
|
||||||
|
|
Loading…
Reference in New Issue