Skip to content

Commit ef75e4e

Browse files
timKraeuterbarmac
authored andcommitted
Implement copying and add test
1 parent 9654edb commit ef75e4e

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

lib/features/modeling/behavior/CreateDataObjectBehavior.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ export default function CreateDataObjectBehavior(eventBus, bpmnFactory) {
2929
// create a DataObject every time a DataObjectReference is created
3030
var dataObject = bpmnFactory.create('bpmn:DataObject');
3131

32+
// Copy the isCollection property if needed.
33+
dataObject.isCollection = shape.businessObject.dataObjectRef?.isCollection || false;
34+
3235
// set the reference to the DataObject
3336
shape.businessObject.dataObjectRef = dataObject;
3437
}

test/spec/features/modeling/behavior/DataObjectBehaviorSpec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,32 @@ describe('features/modeling/behavior - data object', function() {
4545
}));
4646

4747

48+
it('should copy the isCollection property in DataObject if present', inject(function(modeling, copyPaste) {
49+
50+
// when
51+
var dataObjectRefShape = modeling.createShape({ type: 'bpmn:DataObjectReference' },
52+
{ x: 220, y: 220 }, rootShape);
53+
dataObjectRefShape.businessObject.dataObjectRef.isCollection = true;
54+
55+
copyPaste.copy(dataObjectRefShape);
56+
var pastedElements = copyPaste.paste({
57+
element: rootShape,
58+
point: {
59+
x: 350,
60+
y: 150
61+
}
62+
});
63+
64+
var dataObject = pastedElements[0].businessObject.dataObjectRef;
65+
66+
// then
67+
expect(dataObject).to.exist;
68+
expect(is(dataObject, 'bpmn:DataObject')).to.be.true;
69+
expect(dataObject.id).to.exist;
70+
expect(dataObject.isCollection).to.be.true;
71+
}));
72+
73+
4874
it('should create the corresponding DataObject / undo');
4975

5076

0 commit comments

Comments
 (0)