Skip to content

Commit d348b50

Browse files
ssidharth010barmac
andauthored
fix: show modeling feedback error for data objects
Related to camunda/camunda-modeler#4345 --------- Co-authored-by: Maciej Barelkowski <maciejbarel@gmail.com>
1 parent de95b43 commit d348b50

File tree

2 files changed

+39
-15
lines changed

2 files changed

+39
-15
lines changed

lib/features/modeling-feedback/ModelingFeedback.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { is } from '../../util/ModelUtil';
77
*/
88

99
var COLLAB_ERR_MSG = 'flow elements must be children of pools/participants';
10+
var DATA_OBJECT_ERR_MSG = 'Data object must be placed within a pool/participant.';
1011

1112
/**
1213
* @param {EventBus} eventBus
@@ -32,8 +33,12 @@ export default function ModelingFeedback(eventBus, tooltips, translate) {
3233
shape = context.shape,
3334
target = context.target;
3435

35-
if (is(target, 'bpmn:Collaboration') && is(shape, 'bpmn:FlowNode')) {
36-
showError(event, translate(COLLAB_ERR_MSG));
36+
if (is(target, 'bpmn:Collaboration')) {
37+
if (is(shape, 'bpmn:FlowNode')) {
38+
showError(event, translate(COLLAB_ERR_MSG));
39+
} else if (is(shape, 'bpmn:DataObjectReference')) {
40+
showError(event, translate(DATA_OBJECT_ERR_MSG));
41+
}
3742
}
3843
});
3944

test/spec/features/modeling-feedback/ModelingFeedbackSpec.js

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,46 @@ describe('features/modeling - ModelingFeedback', function() {
2525
]
2626
}));
2727

28+
it('should indicate error when placing flow elements inside collaboration', inject(
29+
function(create, canvas, elementFactory, dragging) {
2830

29-
it('should indicate', inject(function(create, canvas, elementFactory, dragging) {
31+
// given
32+
var task = elementFactory.createShape({ type: 'bpmn:Task' });
3033

31-
// given
32-
var task = elementFactory.createShape({ type: 'bpmn:Task' });
34+
var collaboration = canvas.getRootElement();
35+
var collaborationGfx = canvas.getGraphics(collaboration);
3336

34-
var collaboration = canvas.getRootElement();
35-
var collaborationGfx = canvas.getGraphics(collaboration);
37+
create.start(canvasEvent({ x: 100, y: 100 }), task);
38+
dragging.hover({ element: collaboration, gfx: collaborationGfx });
3639

37-
create.start(canvasEvent({ x: 100, y: 100 }), task);
38-
dragging.hover({ element: collaboration, gfx: collaborationGfx });
40+
// when
41+
dragging.end();
3942

40-
// when
41-
dragging.end();
43+
// then
44+
expectTooltip('error', 'flow elements must be children of pools/participants');
45+
}));
4246

43-
// then
44-
expectTooltip('error', 'flow elements must be children of pools/participants');
45-
}));
47+
it('should indicate error when placing data objects inside collaboration', inject(
48+
function(create, canvas, elementFactory, dragging) {
4649

47-
});
50+
// given
51+
var dataObject = elementFactory.createShape({ type: 'bpmn:DataObjectReference' });
52+
53+
var collaboration = canvas.getRootElement();
54+
var collaborationGfx = canvas.getGraphics(collaboration);
55+
56+
create.start(canvasEvent({ x: 150, y: 150 }), dataObject);
57+
dragging.hover({ element: collaboration, gfx: collaborationGfx });
4858

59+
// when
60+
dragging.end();
61+
62+
// then
63+
expectTooltip('error', 'Data object must be placed within a pool/participant.');
64+
}
65+
));
66+
67+
});
4968

5069
function expectTooltip(cls, message) {
5170

0 commit comments

Comments
 (0)