From 40f1d3af52912c6fc9baa7ea9fff625cd3f899b3 Mon Sep 17 00:00:00 2001
From: KHADIR Tayeb <45130488+tkhadir@users.noreply.github.com>
Date: Wed, 7 Apr 2021 11:48:35 +0200
Subject: [PATCH] feat: enable connection tool for text annotation
fixes upstream camunda/camunda-modeler#2042
---
.../context-pad/ContextPadProvider.js | 50 +++++++++++++------
lib/features/rules/BpmnRules.js | 3 +-
.../context-pad/ContextPad.activation.bpmn | 8 ++-
.../context-pad/ContextPadProviderSpec.js | 11 ++++
test/spec/features/rules/BpmnRulesSpec.js | 3 +-
5 files changed, 58 insertions(+), 17 deletions(-)
diff --git a/lib/features/context-pad/ContextPadProvider.js b/lib/features/context-pad/ContextPadProvider.js
index 356af0aed1..0fd1a047b7 100644
--- a/lib/features/context-pad/ContextPadProvider.js
+++ b/lib/features/context-pad/ContextPadProvider.js
@@ -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,
+ },
+ },
});
}
diff --git a/lib/features/rules/BpmnRules.js b/lib/features/rules/BpmnRules.js
index 6c20ff123f..3d56d54d24 100644
--- a/lib/features/rules/BpmnRules.js
+++ b/lib/features/rules/BpmnRules.js
@@ -213,7 +213,8 @@ function canStartConnection(element) {
'bpmn:InteractionNode',
'bpmn:DataObjectReference',
'bpmn:DataStoreReference',
- 'bpmn:Group'
+ 'bpmn:Group',
+ 'bpmn:TextAnnotation'
]);
}
diff --git a/test/spec/features/context-pad/ContextPad.activation.bpmn b/test/spec/features/context-pad/ContextPad.activation.bpmn
index 42e3f24b57..fdf19b8947 100644
--- a/test/spec/features/context-pad/ContextPad.activation.bpmn
+++ b/test/spec/features/context-pad/ContextPad.activation.bpmn
@@ -12,6 +12,9 @@
+
+ simple text annotation
+
@@ -54,6 +57,9 @@
+
+
+
-
\ No newline at end of file
+
diff --git a/test/spec/features/context-pad/ContextPadProviderSpec.js b/test/spec/features/context-pad/ContextPadProviderSpec.js
index 24553ecda8..24a622124b 100644
--- a/test/spec/features/context-pad/ContextPadProviderSpec.js
+++ b/test/spec/features/context-pad/ContextPadProviderSpec.js
@@ -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'
+ ]);
+ }));
+
});
diff --git a/test/spec/features/rules/BpmnRulesSpec.js b/test/spec/features/rules/BpmnRulesSpec.js
index 4d9000440f..10701eb504 100644
--- a/test/spec/features/rules/BpmnRulesSpec.js
+++ b/test/spec/features/rules/BpmnRulesSpec.js
@@ -2255,7 +2255,8 @@ describe('features/modeling/rules - BpmnRules', function() {
'bpmn:InteractionNode',
'bpmn:DataObjectReference',
'bpmn:DataStoreReference',
- 'bpmn:Group'
+ 'bpmn:Group',
+ 'bpmn:TextAnnotation'
];
// when