feat(popup-menu/replace): disallow replace typed event in subprocess

This commit is contained in:
Maximilian Trumpf 2020-07-29 15:30:54 +02:00 committed by MaxTru
parent 4706a407c0
commit 06ca742bc2
3 changed files with 55 additions and 3 deletions

View File

@ -77,8 +77,8 @@ ReplaceMenuProvider.prototype.getEntries = function(element) {
var differentType = isDifferentType(element); var differentType = isDifferentType(element);
// start events outside event sub processes // start events outside sub processes
if (is(businessObject, 'bpmn:StartEvent') && !isEventSubProcess(businessObject.$parent)) { if (is(businessObject, 'bpmn:StartEvent') && !is(businessObject.$parent, 'bpmn:SubProcess')) {
entries = filter(replaceOptions.START_EVENT, differentType); entries = filter(replaceOptions.START_EVENT, differentType);
@ -97,7 +97,6 @@ ReplaceMenuProvider.prototype.getEntries = function(element) {
// start events inside event sub processes // start events inside event sub processes
if (is(businessObject, 'bpmn:StartEvent') && isEventSubProcess(businessObject.$parent)) { if (is(businessObject, 'bpmn:StartEvent') && isEventSubProcess(businessObject.$parent)) {
entries = filter(replaceOptions.EVENT_SUB_PROCESS_START_EVENT, function(entry) { entries = filter(replaceOptions.EVENT_SUB_PROCESS_START_EVENT, function(entry) {
var target = entry.target; var target = entry.target;
@ -114,6 +113,14 @@ ReplaceMenuProvider.prototype.getEntries = function(element) {
return this._createEntries(element, entries); return this._createEntries(element, entries);
} }
// start events inside sub processes
if (is(businessObject, 'bpmn:StartEvent') && !isEventSubProcess(businessObject.$parent)
&& is(businessObject.$parent, 'bpmn:SubProcess')) {
entries = filter(replaceOptions.START_EVENT_SUB_PROCESS, differentType);
return this._createEntries(element, entries);
}
// end events // end events
if (is(businessObject, 'bpmn:EndEvent')) { if (is(businessObject, 'bpmn:EndEvent')) {

View File

@ -61,6 +61,33 @@ export var START_EVENT = [
} }
]; ];
export var START_EVENT_SUB_PROCESS = [
{
label: 'Start Event',
actionName: 'replace-with-none-start',
className: 'bpmn-icon-start-event-none',
target: {
type: 'bpmn:StartEvent'
}
},
{
label: 'Intermediate Throw Event',
actionName: 'replace-with-none-intermediate-throwing',
className: 'bpmn-icon-intermediate-event-none',
target: {
type: 'bpmn:IntermediateThrowEvent'
}
},
{
label: 'End Event',
actionName: 'replace-with-none-end',
className: 'bpmn-icon-end-event-none',
target: {
type: 'bpmn:EndEvent'
}
}
];
export var INTERMEDIATE_EVENT = [ export var INTERMEDIATE_EVENT = [
{ {
label: 'Start Event', label: 'Start Event',

View File

@ -657,6 +657,24 @@ describe('features/popup-menu - replace menu provider', function() {
}) })
); );
it('should contain only start event, end event and intermediate throw event inside sub process except the current one',
inject(function(bpmnReplace, elementRegistry) {
// given
var startEvent = elementRegistry.get('StartEvent_2');
// when
openPopup(startEvent);
// then
expect(queryEntry('replace-with-message-start')).to.be.null;
expect(queryEntry('replace-with-none-end')).to.exist;
expect(queryEntry('replace-with-none-intermediate-throwing')).to.exist;
expect(queryEntries()).to.have.length(2);
})
);
it('should contain all intermediate events except the current one', it('should contain all intermediate events except the current one',
inject(function(bpmnReplace, elementRegistry) { inject(function(bpmnReplace, elementRegistry) {