Skip to content

Commit

Permalink
fix: support collaborations
Browse files Browse the repository at this point in the history
  • Loading branch information
marstamm committed Aug 2, 2024
1 parent c077221 commit 0100794
Show file tree
Hide file tree
Showing 7 changed files with 341 additions and 88 deletions.
48 changes: 35 additions & 13 deletions lib/Components/ElementList/ElementList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,34 @@ function ElementEntry(props) {

const element = elementRegistry.get(bo.id);

if (!element) {
return null;
}

const handleSelect = (event) => {
if (is(element, 'bpmn:Process')) {
let elementToSelect = element;

if (!elementToSelect && is(bo, 'bpmn:Process')) {

// Diagram is a collaboration, we can select the participant
const participant = findParticipant(bo);

if (!participant) {
return;
}

elementToSelect = elementRegistry.get(participant.id);
}

if (!elementToSelect || is(elementToSelect, 'bpmn:Process')) {
return;
}

const multiSelect = event.shiftKey;

if (multiSelect && selection.isSelected(element)) {
selection.deselect(element);
if (multiSelect && selection.isSelected(elementToSelect)) {
selection.deselect(elementToSelect);
return;
}

canvas.scrollToElement(element);
selection.select(element, event.shiftKey);
canvas.scrollToElement(elementToSelect);
selection.select(elementToSelect, event.shiftKey);
};

const selected = selection.get();
Expand All @@ -101,11 +112,11 @@ function ElementEntry(props) {
availableVariables={ availableVariables } />)
.filter(Boolean); // filter out hidden entries. Important for parents visibility

const isSelected = selected.some(s => s.id === bo.id);
const isSelected = selected.some(s => (s.id === bo.id || s.businessObject?.processRef?.id === bo.id));

const shouldShow = hasOwnVariables || (children && children.length) || isSelected || is(element, 'bpmn:Process');

const icon = getSVGComponent(element);
const icon = getSVGComponent(element || bo);

return (
shouldShow && (
Expand All @@ -119,12 +130,23 @@ function ElementEntry(props) {
bo.name || bo.label || bo.id
}
onSelect={ handleSelect }
selected={ selected.map(s => s.id) }
active={ selected.map(s => s.id).includes(bo.id) ? bo.id : null }
selected={ isSelected ? [ bo.id ] : [] }
active={ isSelected ? bo.id : null }
isExpanded={ true }
>
{ children }
</TreeNode>
)
);
}


// helper //////////////////////
function findParticipant(processBo) {
const definition = processBo.$parent;
const collaboration = definition?.get('rootElements')?.find(root => is(root, 'bpmn:Collaboration'));

if (collaboration) {
return collaboration.get('participants').find(participant => participant.processRef === processBo);
}
}
6 changes: 2 additions & 4 deletions lib/Components/ElementList/Icons/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
} from 'bpmn-js/lib/util/ModelUtil';

import {
isExpanded,
isEventSubProcess,
isExpanded,
isInterrupting
} from 'bpmn-js/lib/util/DiUtil';

Expand All @@ -14,9 +14,7 @@ import useService from '../../../hooks/useService';
import iconsByType from './svg';

function getConcreteType(element) {
const {
type: elementType
} = element;
const elementType = element.type || element.$type;

let type = getRawType(elementType);

Expand Down
Loading

0 comments on commit 0100794

Please sign in to comment.