diff --git a/src/components/ReactDiagramEditor.tsx b/src/components/ReactDiagramEditor.tsx index ef5afcb..9c5fef2 100644 --- a/src/components/ReactDiagramEditor.tsx +++ b/src/components/ReactDiagramEditor.tsx @@ -63,6 +63,7 @@ type OwnProps = { diagramXML?: string | null; fileName?: string; onLaunchScriptEditor?: (..._args: any[]) => any; + onElementClick?: (..._args: any[]) => any; url?: string; }; @@ -77,6 +78,7 @@ export default function ReactDiagramEditor({ diagramXML, fileName, onLaunchScriptEditor, + onElementClick, url, }: OwnProps) { const [diagramXMLString, setDiagramXMLString] = useState(''); @@ -174,6 +176,12 @@ export default function ReactDiagramEditor({ } } + function handleElementClick(event: any) { + if (onElementClick) { + onElementClick(event.element); + } + } + setDiagramModelerState(diagramModeler); diagramModeler.on('launch.script.editor', (event: any) => { @@ -183,7 +191,17 @@ export default function ReactDiagramEditor({ } handleLaunchScriptEditor(element); }); - }, [diagramModelerState, diagramType, onLaunchScriptEditor]); + + // 'element.hover', + // 'element.out', + // 'element.click', + // 'element.dblclick', + // 'element.mousedown', + // 'element.mouseup', + diagramModeler.on('element.click', (element: any) => { + handleElementClick(element); + }); + }, [diagramModelerState, diagramType, onLaunchScriptEditor, onElementClick]); useEffect(() => { // These seem to be system tasks that cannot be highlighted diff --git a/src/routes/ProcessInstanceShow.tsx b/src/routes/ProcessInstanceShow.tsx index 398cf87..6a7b371 100644 --- a/src/routes/ProcessInstanceShow.tsx +++ b/src/routes/ProcessInstanceShow.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react'; import { useParams, useNavigate } from 'react-router-dom'; -import { Button, Stack } from 'react-bootstrap'; +import { Button, Modal, Stack } from 'react-bootstrap'; import ProcessBreadcrumb from '../components/ProcessBreadcrumb'; import HttpService from '../services/HttpService'; import ReactDiagramEditor from '../components/ReactDiagramEditor'; @@ -12,6 +12,7 @@ export default function ProcessInstanceShow() { const [processInstance, setProcessInstance] = useState(null); const [tasks, setTasks] = useState(null); + const [taskToDisplay, setTaskToDisplay] = useState(null); const navigateToProcessInstances = (_result: any) => { navigate( @@ -66,24 +67,6 @@ export default function ProcessInstanceShow() { return taskIds; }; - const getTaskData = () => { - let taskData = null; - if (tasks) { - // FIXME: The READY task should be the last in the task list so should contain the data we want - // this may not be accurate though if there are parallell tasks and such so we'll probably need - // a better way to find the most recent task data at some point - (tasks as any).forEach(function getUserTasksElement(task: any) { - if (task.state === 'COMPLETED') { - taskData = task.data; - } - if (task.state === 'READY') { - taskData = task.data; - } - }); - } - return taskData; - }; - const getInfoTag = (processInstanceToUse: any) => { const currentEndDate = convertSecondsToFormattedDate( processInstanceToUse.end_in_seconds @@ -126,9 +109,37 @@ export default function ProcessInstanceShow() { return
; }; + const handleClickedDiagramTask = (shapeElement: any) => { + if (tasks) { + const matchingTask = (tasks as any).find( + (task: any) => task.name === shapeElement.id + ); + if (matchingTask) { + setTaskToDisplay(matchingTask); + } + } + }; + + const handleTaskDataDisplayClose = () => { + setTaskToDisplay(null); + }; + + const taskDataDisplayArea = () => { + if (taskToDisplay) { + return ( +{JSON.stringify((taskToDisplay as any).data, null, 2)}+
{JSON.stringify(taskData, null, 2)}-