fix(replace-preview): rename canExecute.replace -> canExecute.replacements

Closes #346
This commit is contained in:
pedesen 2015-09-01 17:57:32 +02:00
parent d831ed45b8
commit ccf21e2f0c
4 changed files with 30 additions and 9 deletions

View File

@ -30,7 +30,7 @@ function MoveStartEventBehavior(eventBus, bpmnReplace, bpmnRules, elementRegistr
var canReplace = bpmnRules.canReplace(elements, target);
forEach(canReplace.replace, function(replacements) {
forEach(canReplace.replacements, function(replacements) {
var newElement = {
type: replacements.newElementType
@ -43,7 +43,7 @@ function MoveStartEventBehavior(eventBus, bpmnReplace, bpmnRules, elementRegistr
});
if (canReplace.replace) {
if (canReplace.replacements) {
selection.select(elements);
}

View File

@ -21,7 +21,7 @@ function BpmnReplacePreview(eventBus, elementRegistry, elementFactory, canvas, m
*/
function replaceVisual(context) {
var replacements = context.canExecute.replace;
var replacements = context.canExecute.replacements;
forEach(replacements, function(replacement) {
@ -101,7 +101,7 @@ function BpmnReplacePreview(eventBus, elementRegistry, elementFactory, canvas, m
context.visualReplacements = [];
}
if (canExecute.replace) {
if (canExecute.replacements) {
replaceVisual(context);
} else {
restoreVisual(context);

View File

@ -421,7 +421,7 @@ function canReplace(elements, target) {
}
var canExecute = {
replace: []
replacements: []
};
forEach(elements, function(element) {
@ -435,7 +435,7 @@ function canReplace(elements, target) {
element.type !== 'label' &&
canDrop(element, target)) {
canExecute.replace.push({
canExecute.replacements.push({
oldElementId: element.id,
newElementType: 'bpmn:StartEvent'
});
@ -443,7 +443,7 @@ function canReplace(elements, target) {
}
});
return canExecute.replace.length ? canExecute : false;
return canExecute.replacements.length ? canExecute : false;
}
function canMove(elements, target) {

View File

@ -20,8 +20,7 @@ describe('features/replace-preview', function() {
var diagramXML = require('../../../fixtures/bpmn/event-sub-processes.bpmn');
var startEvent_1,
rootElement,
Event;
rootElement;
var getGfx,
moveShape;
@ -244,4 +243,26 @@ describe('features/replace-preview', function() {
}));
it('should not throw TypeError when moving boundaryEvent',
inject(function(move, dragging, elementRegistry, elementFactory, selection, modeling) {
// given
var startEvent_1 = elementRegistry.get('StartEvent_1'),
subProcess_3 = elementRegistry.get('SubProcess_3');
var intermediateEvent = elementFactory.createShape({ type: 'bpmn:IntermediateThrowEvent' });
var boundaryEvent = modeling.createShape(intermediateEvent, { x: 550, y: 180 }, subProcess_3, true);
// when
selection.select([ startEvent_1 ]);
moveShape(boundaryEvent, subProcess_3, { x: 580, y: 210 });
moveShape(boundaryEvent, subProcess_3, { x: 580, y: 180 });
// then
// expect not to throw TypeError: Cannot read property 'oldElementId' of undefined
}));
});