fix(copy-paste): adjust categoryValueRef when group is copied

Closes #958
This commit is contained in:
Niklas Kiefer 2019-05-15 12:49:08 +02:00 committed by merge-me[bot]
parent 576a3dec15
commit 1575b5b26f
3 changed files with 34 additions and 1 deletions

View File

@ -101,6 +101,10 @@ export default function BpmnCopyPaste(
descriptor.parent = rootElement;
}
if (descriptor.type === 'bpmn:Group') {
newBusinessObject.categoryValueRef = oldBusinessObject.categoryValueRef;
}
if (is(parent, 'bpmn:Lane')) {
descriptor.parent = parent.parent;
}

View File

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.2.0-dev">
<bpmn:category id="Category">
<bpmn:categoryValue id="CategoryValue" value="Group" />
</bpmn:category>
<bpmn:process id="Process_1" isExecutable="false">
<bpmn:subProcess id="Sub_non_interrupt" />
<bpmn:subProcess id="Sub_event_subprocess" triggeredByEvent="true" />
@ -11,6 +14,7 @@
<bpmn:timerEventDefinition />
</bpmn:boundaryEvent>
<bpmn:transaction id="Sub_transaction" />
<bpmn:group id="Group" categoryValueRef="CategoryValue" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
@ -38,6 +42,9 @@
<bpmndi:BPMNShape id="Transaction_1so7kki_di" bpmnElement="Sub_transaction" isExpanded="true">
<dc:Bounds x="329" y="207" width="140" height="120" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Group_di" bpmnElement="Group">
<dc:Bounds x="529" y="40" width="140" height="120" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

View File

@ -21,7 +21,10 @@ import {
import DescriptorTree from './DescriptorTree';
import { is } from 'lib/util/ModelUtil';
import {
getBusinessObject,
is
} from 'lib/util/ModelUtil';
describe('features/copy-paste', function() {
@ -403,6 +406,25 @@ describe('features/copy-paste', function() {
})
);
it('should copy & paste groups',
inject(function(elementRegistry, canvas, copyPaste, modeling) {
// when
copyPasteElement(elementRegistry, canvas, copyPaste, modeling, 'Group');
var group = elementRegistry.filter(function(element) {
return element.type === 'bpmn:Group';
})[0];
var categoryValue = getBusinessObject(group).categoryValueRef;
expect(group).to.exist;
expect(categoryValue).to.exist;
expect(categoryValue.id).to.equal('CategoryValue');
})
);
});