fix(replace-menu): only allow cancel boundary events on transactions
related to camunda/camunda-modeler#2026
This commit is contained in:
parent
12999fbe3b
commit
2e9f617911
|
@ -155,7 +155,7 @@ ReplaceMenuProvider.prototype.getEntries = function(element) {
|
|||
|
||||
var target = entry.target;
|
||||
|
||||
if (target.eventDefinition == 'bpmn:CancelEventDefinition' &&
|
||||
if (target.eventDefinitionType == 'bpmn:CancelEventDefinition' &&
|
||||
!is(businessObject.attachedToRef, 'bpmn:Transaction')) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?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">
|
||||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/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="4.3.0">
|
||||
<bpmn:process id="Process_1" isExecutable="false">
|
||||
<bpmn:transaction id="Transaction_1">
|
||||
<bpmn:endEvent id="EndEvent_1">
|
||||
|
@ -11,39 +11,58 @@
|
|||
<bpmn:endEvent id="EndEvent_2" />
|
||||
</bpmn:subProcess>
|
||||
<bpmn:boundaryEvent id="BoundaryEvent_2" attachedToRef="SubProcess_1" />
|
||||
<bpmn:transaction id="Transaction_2">
|
||||
<bpmn:endEvent id="EndEvent_3">
|
||||
<bpmn:messageEventDefinition id="MessageEventDefinition_0jj8o4w" />
|
||||
</bpmn:endEvent>
|
||||
</bpmn:transaction>
|
||||
<bpmn:task id="Activity_1" />
|
||||
<bpmn:boundaryEvent id="BoundaryEvent_3" attachedToRef="Activity_1" />
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
|
||||
<bpmndi:BPMNShape id="EndEvent_2_di" bpmnElement="EndEvent_2">
|
||||
<dc:Bounds x="555" y="131" width="36" height="36" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="528" y="167" width="90" height="20" />
|
||||
</bpmndi:BPMNLabel>
|
||||
<bpmndi:BPMNShape id="Activity_1rswf6m_di" bpmnElement="Activity_1">
|
||||
<dc:Bounds x="630" y="400" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Transaction_1_di" bpmnElement="Transaction_1" isExpanded="true">
|
||||
<dc:Bounds x="46" y="45" width="350" height="200" />
|
||||
<dc:Bounds x="156" y="45" width="350" height="200" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="EndEvent_1_di" bpmnElement="EndEvent_1">
|
||||
<dc:Bounds x="208" y="126" width="36" height="36" />
|
||||
<dc:Bounds x="318" y="126" width="36" height="36" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="181" y="162" width="90" height="20" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="BoundaryEvent_1_di" bpmnElement="BoundaryEvent_1">
|
||||
<dc:Bounds x="96" y="227" width="36" height="36" />
|
||||
<bpmndi:BPMNShape id="SubProcess_1_di" bpmnElement="SubProcess_1" isExpanded="true">
|
||||
<dc:Bounds x="564" y="45" width="350" height="200" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="EndEvent_2_di" bpmnElement="EndEvent_2">
|
||||
<dc:Bounds x="665" y="131" width="36" height="36" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="379" y="350" width="90" height="20" />
|
||||
<dc:Bounds x="528" y="167" width="90" height="20" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="SubProcess_1_di" bpmnElement="SubProcess_1" isExpanded="true">
|
||||
<dc:Bounds x="454" y="45" width="350" height="200" />
|
||||
<bpmndi:BPMNShape id="Activity_0hggfqa_di" bpmnElement="Transaction_2" isExpanded="true">
|
||||
<dc:Bounds x="156" y="370" width="350" height="200" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Event_1fewq9p_di" bpmnElement="EndEvent_3">
|
||||
<dc:Bounds x="318" y="451" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="BoundaryEvent_2_di" bpmnElement="BoundaryEvent_2">
|
||||
<dc:Bounds x="483" y="227" width="36" height="36" />
|
||||
<dc:Bounds x="593" y="227" width="36" height="36" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="680" y="350" width="90" height="20" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="BoundaryEvent_1_di" bpmnElement="BoundaryEvent_1">
|
||||
<dc:Bounds x="206" y="227" width="36" height="36" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="379" y="350" width="90" height="20" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Event_1fm3j1i_di" bpmnElement="BoundaryEvent_3">
|
||||
<dc:Bounds x="662" y="462" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
||||
|
|
|
@ -479,7 +479,7 @@ describe('features - context-pad', function() {
|
|||
// then
|
||||
var replaceMenu = domQueryAll('[data-id$="-boundary"]', popupMenu._current.container);
|
||||
expect(replaceMenu).to.exist;
|
||||
expect(replaceMenu.length).to.eql(13);
|
||||
expect(replaceMenu.length).to.eql(12);
|
||||
}
|
||||
));
|
||||
|
||||
|
@ -630,4 +630,4 @@ function padEvent(entry) {
|
|||
clientY: 100
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -315,7 +315,7 @@ describe('features/modeling - move start event behavior', function() {
|
|||
commandStack.undo();
|
||||
|
||||
var afterBoundaryEvent = elementRegistry.filter(function(element) {
|
||||
return (element.type === 'bpmn:BoundaryEvent' && element.id !== 'BoundaryEvent_2');
|
||||
return (element.type === 'bpmn:BoundaryEvent' && element.id === 'BoundaryEvent_1');
|
||||
})[0];
|
||||
|
||||
// then
|
||||
|
@ -344,7 +344,7 @@ describe('features/modeling - move start event behavior', function() {
|
|||
modeling.moveElements([ newBoundaryEvent ], { x: 500, y: 0 }, subProcess, ATTACH);
|
||||
|
||||
var movedBoundaryEvent = elementRegistry.filter(function(element) {
|
||||
return (element.type === 'bpmn:BoundaryEvent' && element.id !== 'BoundaryEvent_2');
|
||||
return (element.type === 'bpmn:BoundaryEvent' && element.id === 'BoundaryEvent_1');
|
||||
})[0];
|
||||
|
||||
// then
|
||||
|
@ -378,7 +378,7 @@ describe('features/modeling - move start event behavior', function() {
|
|||
commandStack.undo();
|
||||
|
||||
var movedBoundaryEvent = elementRegistry.filter(function(element) {
|
||||
return (element.type === 'bpmn:BoundaryEvent' && element.id !== 'BoundaryEvent_2');
|
||||
return (element.type === 'bpmn:BoundaryEvent' && element.id === 'BoundaryEvent_1');
|
||||
})[0];
|
||||
|
||||
// then
|
||||
|
|
|
@ -39,18 +39,6 @@ describe('features/popup-menu - replace menu provider', function() {
|
|||
customRulesModule
|
||||
];
|
||||
|
||||
var openPopup = function(element, offset) {
|
||||
offset = offset || 100;
|
||||
|
||||
getBpmnJS().invoke(function(popupMenu) {
|
||||
|
||||
popupMenu.open(element, 'bpmn-replace', {
|
||||
x: element.x + offset, y: element.y + offset
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
describe('data object - collection marker', function() {
|
||||
|
||||
|
@ -952,70 +940,120 @@ describe('features/popup-menu - replace menu provider', function() {
|
|||
});
|
||||
|
||||
|
||||
describe('cancel events', function() {
|
||||
describe('cancel event definition', function() {
|
||||
|
||||
var diagramXML = require('../../../fixtures/bpmn/features/replace/cancel-events.bpmn');
|
||||
|
||||
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
||||
|
||||
it('should contain cancel event replace option',
|
||||
inject(function(elementRegistry) {
|
||||
|
||||
// given
|
||||
var endEvent = elementRegistry.get('EndEvent_1');
|
||||
describe('for end events', function() {
|
||||
|
||||
// when
|
||||
openPopup(endEvent);
|
||||
it('should contain cancel event replace option in transaction',
|
||||
inject(function(elementRegistry) {
|
||||
|
||||
// then
|
||||
expect(queryEntries()).to.have.length(9);
|
||||
})
|
||||
);
|
||||
// given
|
||||
var endEvent = elementRegistry.get('EndEvent_3');
|
||||
|
||||
// when
|
||||
openPopup(endEvent);
|
||||
|
||||
// then
|
||||
expect(queryEntries()).to.have.length(9);
|
||||
|
||||
expect(queryEntry('replace-with-cancel-end')).to.exist;
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
it('should NOT contain cancel event replace option',
|
||||
inject(function(elementRegistry) {
|
||||
it('should NOT contain cancel event replace option in transaction when already set',
|
||||
inject(function(elementRegistry) {
|
||||
|
||||
// given
|
||||
var endEvent = elementRegistry.get('EndEvent_2');
|
||||
// given
|
||||
var endEvent = elementRegistry.get('EndEvent_1');
|
||||
|
||||
// when
|
||||
openPopup(endEvent);
|
||||
// when
|
||||
openPopup(endEvent);
|
||||
|
||||
// then
|
||||
expect(queryEntries()).to.have.length(8);
|
||||
})
|
||||
);
|
||||
// then
|
||||
expect(queryEntries()).to.have.length(9);
|
||||
expect(queryEntry('replace-with-cancel-end')).to.be.null;
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
it('should contain cancel event replace option (boundary events)',
|
||||
inject(function(elementRegistry) {
|
||||
it('should NOT contain cancel event replace option outside transaction',
|
||||
inject(function(elementRegistry) {
|
||||
|
||||
// given
|
||||
var boundaryEvent = elementRegistry.get('BoundaryEvent_1');
|
||||
// given
|
||||
var endEvent = elementRegistry.get('EndEvent_2');
|
||||
|
||||
// when
|
||||
openPopup(boundaryEvent);
|
||||
// when
|
||||
openPopup(endEvent);
|
||||
|
||||
// then
|
||||
expect(queryEntries()).to.have.length(13);
|
||||
})
|
||||
);
|
||||
// then
|
||||
expect(queryEntries()).to.have.length(8);
|
||||
|
||||
expect(queryEntry('replace-with-cancel-end')).to.be.null;
|
||||
})
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
|
||||
it('should NOT contain cancel event replace option (boundary events)',
|
||||
inject(function(elementRegistry) {
|
||||
describe('for boundary events', function() {
|
||||
|
||||
// given
|
||||
var boundaryEvent = elementRegistry.get('BoundaryEvent_2');
|
||||
it('should contain cancel event replace option attachted to Transaction',
|
||||
inject(function(elementRegistry) {
|
||||
|
||||
// when
|
||||
openPopup(boundaryEvent, 40);
|
||||
// given
|
||||
var boundaryEvent = elementRegistry.get('BoundaryEvent_1');
|
||||
|
||||
// then
|
||||
expect(queryEntries()).to.have.length(13);
|
||||
})
|
||||
);
|
||||
// when
|
||||
openPopup(boundaryEvent);
|
||||
|
||||
// then
|
||||
expect(queryEntries()).to.have.length(13);
|
||||
|
||||
expect(queryEntry('replace-with-cancel-boundary')).to.exist;
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
it('should NOT contain cancel event replace option attached to SubProcess',
|
||||
inject(function(elementRegistry) {
|
||||
|
||||
// given
|
||||
var boundaryEvent = elementRegistry.get('BoundaryEvent_2');
|
||||
|
||||
// when
|
||||
openPopup(boundaryEvent);
|
||||
|
||||
// then
|
||||
expect(queryEntries()).to.have.length(12);
|
||||
|
||||
expect(queryEntry('replace-with-cancel-boundary')).to.be.null;
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
it('should NOT contain cancel event replace option attached to Activity',
|
||||
inject(function(elementRegistry) {
|
||||
|
||||
// given
|
||||
var boundaryEvent = elementRegistry.get('BoundaryEvent_3');
|
||||
|
||||
// when
|
||||
openPopup(boundaryEvent);
|
||||
|
||||
// then
|
||||
expect(queryEntries()).to.have.length(12);
|
||||
|
||||
expect(queryEntry('replace-with-cancel-boundary')).to.be.null;
|
||||
})
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
@ -1024,7 +1062,7 @@ describe('features/popup-menu - replace menu provider', function() {
|
|||
|
||||
beforeEach(bootstrapModeler(diagramXMLReplace, { modules: testModules }));
|
||||
|
||||
it('should contain all boundary events for an interrupting boundary event',
|
||||
it('should contain all boundary events (except for cancel and currently active) for an interrupting boundary event',
|
||||
inject(function(bpmnReplace, elementRegistry) {
|
||||
|
||||
// given
|
||||
|
@ -1035,12 +1073,13 @@ describe('features/popup-menu - replace menu provider', function() {
|
|||
|
||||
// then
|
||||
expect(queryEntry('replace-with-conditional-intermediate-catch')).to.be.null;
|
||||
expect(queryEntries()).to.have.length(12);
|
||||
expect(queryEntry('replace-with-cancel-boundary')).to.be.null;
|
||||
expect(queryEntries()).to.have.length(11);
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
it('should contain all boundary events for a non interrupting boundary event',
|
||||
it('should contain all boundary events (except for cancel and currently active) for a non interrupting boundary event',
|
||||
inject(function(bpmnReplace, elementRegistry) {
|
||||
|
||||
// given
|
||||
|
@ -1051,7 +1090,8 @@ describe('features/popup-menu - replace menu provider', function() {
|
|||
|
||||
// then
|
||||
expect(queryEntry('replace-with-non-interrupting-message-intermediate-catch')).to.be.null;
|
||||
expect(queryEntries()).to.have.length(12);
|
||||
expect(queryEntry('replace-with-cancel-boundary')).to.be.null;
|
||||
expect(queryEntries()).to.have.length(11);
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -2268,6 +2308,18 @@ describe('features/popup-menu - replace menu provider', function() {
|
|||
|
||||
// helpers ////////////
|
||||
|
||||
function openPopup(element, offset) {
|
||||
offset = offset || 100;
|
||||
|
||||
getBpmnJS().invoke(function(popupMenu) {
|
||||
|
||||
popupMenu.open(element, 'bpmn-replace', {
|
||||
x: element.x + offset, y: element.y + offset
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function queryEntry(id) {
|
||||
var container = getBpmnJS().get('canvas').getContainer();
|
||||
|
||||
|
|
Loading…
Reference in New Issue