Skip to content

Commit

Permalink
feat: enable connection tool for text annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
tkhadir authored and MaxTru committed Apr 7, 2021
1 parent c58af15 commit 40f1d3a
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 17 deletions.
50 changes: 36 additions & 14 deletions lib/features/context-pad/ContextPadProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,27 +362,49 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
});
}

if (isAny(businessObject, [
'bpmn:FlowNode',
'bpmn:InteractionNode',
'bpmn:DataObjectReference',
'bpmn:DataStoreReference'
])) {

if (
isAny(businessObject, [
'bpmn:FlowNode',
'bpmn:InteractionNode',
'bpmn:DataObjectReference',
'bpmn:DataStoreReference',
])
) {
assign(actions, {
'append.text-annotation': appendAction('bpmn:TextAnnotation', 'bpmn-icon-text-annotation'),
'append.text-annotation': appendAction(
'bpmn:TextAnnotation',
'bpmn-icon-text-annotation'
),

'connect': {
group: 'connect',
className: 'bpmn-icon-connection-multi',
title: translate('Connect using ' +
(businessObject.isForCompensation ? '' : 'Sequence/MessageFlow or ') +
'Association'),
title: translate(
'Connect using ' +
(businessObject.isForCompensation
? ''
: 'Sequence/MessageFlow or ') +
'Association'
),
action: {
click: startConnect,
dragstart: startConnect
}
}
dragstart: startConnect,
},
},
});
}

if (is(businessObject, 'bpmn:TextAnnotation')) {
assign(actions, {
'connect': {
group: 'connect',
className: 'bpmn-icon-connection-multi',
title: translate('Connect using Association'),
action: {
click: startConnect,
dragstart: startConnect,
},
},
});
}

Expand Down
3 changes: 2 additions & 1 deletion lib/features/rules/BpmnRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ function canStartConnection(element) {
'bpmn:InteractionNode',
'bpmn:DataObjectReference',
'bpmn:DataStoreReference',
'bpmn:Group'
'bpmn:Group',
'bpmn:TextAnnotation'
]);
}

Expand Down
8 changes: 7 additions & 1 deletion test/spec/features/context-pad/ContextPad.activation.bpmn
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<bpmn2:dataObject id="DataObject_1" name="Data Object 1"/>
<bpmn2:dataObjectReference id="DataObjectReference" dataObjectRef="DataObject_1"/>
<bpmn2:group id="Group_1" categoryValueRef="CategoryValue_1" />
<bpmn2:textAnnotation id="TextAnnotation_1">
<bpmn2:text>simple text annotation</bpmn2:text>
</bpmn2:textAnnotation>
</bpmn2:process>
<bpmn2:category id="Category_1">
<bpmn2:categoryValue id="CategoryValue_1" />
Expand Down Expand Up @@ -54,6 +57,9 @@
<bpmndi:BPMNShape id="Group_1_di" bpmnElement="Group_1">
<dc:Bounds x="40" y="410" width="190" height="110" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="TextAnnotation_1_di" bpmnElement="TextAnnotation_1">
<dc:Bounds x="760" y="120" width="100" height="30" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
</bpmn2:definitions>
11 changes: 11 additions & 0 deletions test/spec/features/context-pad/ContextPadProviderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,17 @@ describe('features - context-pad', function() {
]);
}));


it('should provide Text Annotation entries', inject(function() {

expectContextPadEntries('TextAnnotation_1', [
'connect',
'delete',
'!replace',
'!append.text-annotation'
]);
}));

});


Expand Down
3 changes: 2 additions & 1 deletion test/spec/features/rules/BpmnRulesSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2255,7 +2255,8 @@ describe('features/modeling/rules - BpmnRules', function() {
'bpmn:InteractionNode',
'bpmn:DataObjectReference',
'bpmn:DataStoreReference',
'bpmn:Group'
'bpmn:Group',
'bpmn:TextAnnotation'
];

// when
Expand Down

0 comments on commit 40f1d3a

Please sign in to comment.