fix(context-pad): use current context shape

Relates to camunda/camunda-modeler#415
This commit is contained in:
Vladimirs Katusenoks 2016-09-19 11:39:33 +02:00
parent 7177e3af27
commit 38c81146a3
2 changed files with 33 additions and 3 deletions

View File

@ -34,10 +34,15 @@ function ContextPadProvider(eventBus, contextPad, modeling, elementFactory,
eventBus.on('create.end', 250, function(event) { eventBus.on('create.end', 250, function(event) {
var shape = event.shape, var shape = event.context.shape;
entries = contextPad.getEntries(shape);
if (hasPrimaryModifier(event) && entries.replace) { if (!hasPrimaryModifier(event)) {
return;
}
var entries = contextPad.getEntries(shape);
if (entries.replace) {
entries.replace.action.click(event, shape); entries.replace.action.click(event, shape);
} }
}); });

View File

@ -383,6 +383,31 @@ describe('features - context-pad', function() {
})); }));
it('should open boundary event replace menu after an element is created if it has modifier key',
inject(function(create, dragging, canvas, elementFactory, modeling, popupMenu) {
// given
var rootShape = canvas.getRootElement();
var task = elementFactory.createShape({ type: 'bpmn:Task' });
var intermediateEvent = elementFactory.createShape({ type: 'bpmn:IntermediateThrowEvent' });
modeling.createShape(task, { x: 100, y: 100 }, rootShape);
// when
create.start(canvasEvent({ x: 0, y: 0 }), intermediateEvent);
dragging.move(canvasEvent({ x: 50, y: 50 }));
dragging.hover({ element: task });
dragging.move(canvasEvent({ x: 50, y: 65 }));
dragging.end(canvasEvent({ x: 50, y: 65 }, { ctrlKey: true, metaKey: true }));
// then
var replaceMenu = domQuery.all('[data-id$="-boundary"]', popupMenu._current.container);
expect(replaceMenu).to.exist;
expect(replaceMenu.length).to.eql(13);
}));
it('should not open the replace menu after an element is created when there is none', it('should not open the replace menu after an element is created when there is none',
inject(function(create, dragging, canvas, elementFactory) { inject(function(create, dragging, canvas, elementFactory) {
// given // given