fix(contextpad): add signal event to end event replace menu

close #211 #218
This commit is contained in:
jdotzki 2015-03-03 17:09:54 +01:00
parent 5604e13468
commit f527096ac2
2 changed files with 31 additions and 24 deletions

View File

@ -2,7 +2,9 @@
var startEventReplace = [
{
options: {},
options: {
eventDefinition: ''
},
label: 'Start Event',
actionName: 'replace-with-none-start',
className: 'icon-01-none-start',
@ -120,7 +122,7 @@ var startEventReplace = [
}
},
{
label: 'Timer Intermediate Catch Event',
label: 'Escalation Intermediate Catch Event',
actionName: 'replace-with-escalation-throwing',
className: 'icon-04-escalation-intermediate-throwing',
targetType: 'bpmn:IntermediateCatchEvent',
@ -198,10 +200,12 @@ var endEventReplace = [
},
{
label: 'End Event',
actionName: 'replace-with-message-end',
actionName: 'replace-with-none-end',
className: 'icon-01-none-end',
targetType: 'bpmn:EndEvent',
options: {},
options: {
eventDefinition: ''
},
},
{
label: 'Message End Event',
@ -248,6 +252,15 @@ var endEventReplace = [
eventDefinition: 'bpmn:CompensateEventDefinition'
}
},
{
label: 'Signal End Event',
actionName: 'replace-with-signal-end',
className: 'icon-10-signal-end',
targetType: 'bpmn:EndEvent',
options: {
eventDefinition: 'bpmn:SignalEventDefinition'
}
},
{
label: 'Terminate End Event',
actionName: 'replace-with-terminate-end',

View File

@ -21,31 +21,14 @@ function getReplacementMenuEntries(element, replaceElement) {
if (bo.$instanceOf('bpmn:StartEvent')) {
addEntries(startEventReplace, function(entry) {
var eventDefinition = bo.eventDefinition ? bo.eventDefinition[0].$type : '';
return entry.options.eventDefinition !== eventDefinition.$type;
});
addEntries(startEventReplace, filterEvents);
} else if (bo.$instanceOf('bpmn:IntermediateCatchEvent') ||
bo.$instanceOf('bpmn:IntermediateThrowEvent')) {
addEntries(intermediateEventReplace, function(entry) {
var eventDefinition = bo.eventDefinitions ? bo.eventDefinitions[0].$type : '';
var isEventDefinitionEqual = entry.options.eventDefinition === eventDefinition;
var isEventTypeEqual = bo.$type === entry.targetType;
return ((!isEventDefinitionEqual && isEventTypeEqual) ||
!isEventTypeEqual) ||
!(isEventDefinitionEqual && isEventTypeEqual);
});
addEntries(intermediateEventReplace, filterEvents);
} else if (bo.$instanceOf('bpmn:EndEvent')) {
addEntries(endEventReplace, function(entry) {
var eventDefinition = bo.eventDefinition ? bo.eventDefinition[0].$type : '';
return entry.options.eventDefinition !== eventDefinition.$type;
});
addEntries(endEventReplace, filterEvents);
} else if (bo.$instanceOf('bpmn:Gateway')) {
addEntries(gatewayReplace, function(entry) {
@ -60,6 +43,17 @@ function getReplacementMenuEntries(element, replaceElement) {
});
}
function filterEvents(entry) {
var eventDefinition = bo.eventDefinitions ? bo.eventDefinitions[0].$type : '';
var isEventDefinitionEqual = entry.options.eventDefinition === eventDefinition;
var isEventTypeEqual = bo.$type === entry.targetType;
return ((!isEventDefinitionEqual && isEventTypeEqual) ||
!isEventTypeEqual) ||
!(isEventDefinitionEqual && isEventTypeEqual);
}
function addEntries(entries, filterFun) {
// Filter selected type from the array
var filteredEntries = filter(entries, filterFun);