feat(copy-paste): copy Event Sub Process / Non-Interrupting Boundary
Closes #556, #555
This commit is contained in:
parent
1b17d45260
commit
b43cff1ec2
|
@ -10,7 +10,7 @@ var map = require('lodash/collection/map'),
|
|||
|
||||
function setProperties(descriptor, data, properties) {
|
||||
forEach(properties, function(property) {
|
||||
if (data[property]) {
|
||||
if (data[property] !== undefined) {
|
||||
descriptor[property] = data[property];
|
||||
}
|
||||
});
|
||||
|
@ -43,7 +43,9 @@ function BpmnCopyPaste(bpmnFactory, eventBus, copyPaste, clipboard, moddle, canv
|
|||
'processRef',
|
||||
'isInterrupting',
|
||||
'isForCompensation',
|
||||
'associationDirection'
|
||||
'associationDirection',
|
||||
'triggeredByEvent',
|
||||
'cancelActivity'
|
||||
]);
|
||||
|
||||
if (businessObject.default) {
|
||||
|
@ -138,7 +140,11 @@ function BpmnCopyPaste(bpmnFactory, eventBus, copyPaste, clipboard, moddle, canv
|
|||
|
||||
setProperties(businessObject, descriptor, [
|
||||
'name',
|
||||
'text'
|
||||
'text',
|
||||
'isExpanded',
|
||||
'isInterrupting',
|
||||
'cancelActivity',
|
||||
'triggeredByEvent'
|
||||
]);
|
||||
|
||||
if (descriptor.loopCharacteristics) {
|
||||
|
@ -176,7 +182,10 @@ function BpmnCopyPaste(bpmnFactory, eventBus, copyPaste, clipboard, moddle, canv
|
|||
'text',
|
||||
'eventDefinitions',
|
||||
'conditionExpression',
|
||||
'loopCharacteristics'
|
||||
'loopCharacteristics',
|
||||
'isInterrupting',
|
||||
'cancelActivity',
|
||||
'triggeredByEvent'
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
@ -192,4 +201,4 @@ BpmnCopyPaste.$inject = [
|
|||
'bpmnRules'
|
||||
];
|
||||
|
||||
module.exports = BpmnCopyPaste;
|
||||
module.exports = BpmnCopyPaste;
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
<?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:process id="Process_1" isExecutable="false">
|
||||
<bpmn:subProcess id="Sub_non_interrupt" />
|
||||
<bpmn:subProcess id="Sub_event_subprocess" triggeredByEvent="true" />
|
||||
<bpmn:boundaryEvent id="BoundaryEvent_1ttq5yj" cancelActivity="false" attachedToRef="Sub_non_interrupt">
|
||||
<bpmn:messageEventDefinition />
|
||||
</bpmn:boundaryEvent>
|
||||
<bpmn:subProcess id="Sub_interrupt" />
|
||||
<bpmn:boundaryEvent id="BoundaryEvent_0w2tz4k" attachedToRef="Sub_interrupt">
|
||||
<bpmn:timerEventDefinition />
|
||||
</bpmn:boundaryEvent>
|
||||
<bpmn:transaction id="Sub_transaction" />
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
|
||||
<bpmndi:BPMNShape id="SubProcess_1pvi3qq_di" bpmnElement="Sub_non_interrupt" isExpanded="true">
|
||||
<dc:Bounds x="111" y="40" width="140" height="120" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="SubProcess_0k446tj_di" bpmnElement="Sub_event_subprocess" isExpanded="true">
|
||||
<dc:Bounds x="329" y="40" width="140" height="120" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="BoundaryEvent_1a6busd_di" bpmnElement="BoundaryEvent_1ttq5yj">
|
||||
<dc:Bounds x="119" y="142" width="36" height="36" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="92" y="178" width="90" height="20" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="SubProcess_0pj87vw_di" bpmnElement="Sub_interrupt" isExpanded="true">
|
||||
<dc:Bounds x="111" y="207" width="140" height="120" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="BoundaryEvent_1aqt6gt_di" bpmnElement="BoundaryEvent_0w2tz4k">
|
||||
<dc:Bounds x="124" y="309" width="36" height="36" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="97" y="345" width="90" height="20" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Transaction_1so7kki_di" bpmnElement="Sub_transaction" isExpanded="true">
|
||||
<dc:Bounds x="329" y="207" width="140" height="120" />
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
|
@ -22,6 +22,7 @@ describe('features/copy-paste', function() {
|
|||
var testModules = [ bpmnCopyPasteModule, copyPasteModule, tooltipsModule, modelingModule, coreModule ];
|
||||
|
||||
var basicXML = require('../../../fixtures/bpmn/features/copy-paste/basic.bpmn'),
|
||||
propertiesXML = require('../../../fixtures/bpmn/features/copy-paste/properties.bpmn'),
|
||||
collaborationXML = require('../../../fixtures/bpmn/features/copy-paste/collaboration.bpmn'),
|
||||
collaborationMultipleXML = require('../../../fixtures/bpmn/features/copy-paste/collaboration-multiple.bpmn'),
|
||||
collaborationAssociations = require('../../../fixtures/bpmn/features/copy-paste/data-associations.bpmn');
|
||||
|
@ -78,7 +79,7 @@ describe('features/copy-paste', function() {
|
|||
seqFlowLabel = seqFlow.label,
|
||||
task = elementRegistry.get('Task_1fo63a7'),
|
||||
rootElement = canvas.getRootElement(),
|
||||
newStrtEvt, newSeqFlow;
|
||||
newEvent, newFlow;
|
||||
|
||||
// when
|
||||
copyPaste.copy([ startEvent, task ]);
|
||||
|
@ -91,20 +92,20 @@ describe('features/copy-paste', function() {
|
|||
}
|
||||
});
|
||||
|
||||
newStrtEvt = elementRegistry.filter(function(element) {
|
||||
newEvent = elementRegistry.filter(function(element) {
|
||||
return element.parent === rootElement && element.type === 'bpmn:StartEvent';
|
||||
})[0];
|
||||
|
||||
newSeqFlow = elementRegistry.filter(function(element) {
|
||||
newFlow = elementRegistry.filter(function(element) {
|
||||
return element.parent === rootElement && element.type === 'bpmn:SequenceFlow';
|
||||
})[0];
|
||||
|
||||
// then
|
||||
expect(newStrtEvt.label.x - newStrtEvt.x).to.equal(startEventLabel.x - startEvent.x);
|
||||
expect(newStrtEvt.label.y - newStrtEvt.y).to.equal(startEventLabel.y - startEvent.y);
|
||||
expect(newEvent.label.x - newEvent.x).to.equal(startEventLabel.x - startEvent.x);
|
||||
expect(newEvent.label.y - newEvent.y).to.equal(startEventLabel.y - startEvent.y);
|
||||
|
||||
expect(newSeqFlow.label.x - newSeqFlow.waypoints[0].x).to.equal(seqFlowLabel.x - seqFlow.waypoints[0].x);
|
||||
expect(newSeqFlow.label.y - newSeqFlow.waypoints[0].y).to.equal(seqFlowLabel.y - seqFlow.waypoints[0].y);
|
||||
expect(newFlow.label.x - newFlow.waypoints[0].x).to.equal(seqFlowLabel.x - seqFlow.waypoints[0].x);
|
||||
expect(newFlow.label.y - newFlow.waypoints[0].y).to.equal(seqFlowLabel.y - seqFlow.waypoints[0].y);
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -203,6 +204,105 @@ describe('features/copy-paste', function() {
|
|||
});
|
||||
|
||||
|
||||
describe('properties', function() {
|
||||
|
||||
beforeEach(bootstrapModeler(propertiesXML, { modules: testModules }));
|
||||
|
||||
var subProcesses = [
|
||||
'Sub_non_interrupt',
|
||||
'Sub_event_subprocess',
|
||||
'Sub_interrupt',
|
||||
'Sub_transaction'
|
||||
];
|
||||
|
||||
function copyPasteElement(elementRegistry, canvas, copyPaste, modeling, element) {
|
||||
// given
|
||||
var elem = elementRegistry.get(element),
|
||||
rootElement = canvas.getRootElement();
|
||||
|
||||
// when
|
||||
copyPaste.copy(elem);
|
||||
|
||||
modeling.removeElements([ elem ]);
|
||||
|
||||
copyPaste.paste({
|
||||
element: rootElement,
|
||||
point: {
|
||||
x: 175,
|
||||
y: 450
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
it('should copy & paste non interrupting (boundary) events',
|
||||
inject(function(elementRegistry, canvas, copyPaste, modeling) {
|
||||
|
||||
// when
|
||||
copyPasteElement(elementRegistry, canvas, copyPaste, modeling, 'Sub_non_interrupt');
|
||||
|
||||
var subProcess = elementRegistry.filter(function(element) {
|
||||
return element.type === 'bpmn:SubProcess' && (subProcesses.indexOf(element.id) === -1);
|
||||
})[0];
|
||||
|
||||
var nonInterruptEvt = subProcess.attachers[0].businessObject;
|
||||
|
||||
// then
|
||||
expect(nonInterruptEvt.cancelActivity).to.be.false;
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
it('should copy & paste event sub processes',
|
||||
inject(function(elementRegistry, canvas, copyPaste, modeling) {
|
||||
|
||||
// when
|
||||
copyPasteElement(elementRegistry, canvas, copyPaste, modeling, 'Sub_event_subprocess');
|
||||
|
||||
var subProcess = elementRegistry.filter(function(element) {
|
||||
return element.type === 'bpmn:SubProcess' && (subProcesses.indexOf(element.id) === -1);
|
||||
})[0];
|
||||
|
||||
expect(subProcess.businessObject.triggeredByEvent).to.be.true;
|
||||
expect(subProcess.businessObject.isExpanded).to.be.true;
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
it('should copy & paste interrupting (boundary) events',
|
||||
inject(function(elementRegistry, canvas, copyPaste, modeling) {
|
||||
|
||||
// when
|
||||
copyPasteElement(elementRegistry, canvas, copyPaste, modeling, 'Sub_interrupt');
|
||||
|
||||
var subProcess = elementRegistry.filter(function(element) {
|
||||
return element.type === 'bpmn:SubProcess' && (subProcesses.indexOf(element.id) === -1);
|
||||
})[0];
|
||||
|
||||
var interruptEvt = subProcess.attachers[0].businessObject;
|
||||
|
||||
// then
|
||||
expect(interruptEvt.cancelActivity).to.be.true;
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
it('should copy & paste transactions',
|
||||
inject(function(elementRegistry, canvas, copyPaste, modeling) {
|
||||
|
||||
// when
|
||||
copyPasteElement(elementRegistry, canvas, copyPaste, modeling, 'Sub_transaction');
|
||||
|
||||
var transaction = elementRegistry.filter(function(element) {
|
||||
return element.type === 'bpmn:Transaction';
|
||||
})[0];
|
||||
|
||||
expect(transaction).to.exist;
|
||||
})
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe('basic collaboration', function() {
|
||||
|
||||
beforeEach(bootstrapModeler(collaborationXML, { modules: testModules }));
|
||||
|
@ -543,4 +643,4 @@ function expectCollection(collA, collB, contains) {
|
|||
expect(collA).to.not.contain(element);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue