Skip to content

Commit

Permalink
feat(palette): select start event when creating sub process
Browse files Browse the repository at this point in the history
* use autoSelect hint to only select start event after create

Related to #1152
  • Loading branch information
Niklas Kiefer authored and philippfromme committed Aug 9, 2019
1 parent 2dd483b commit 20114ae
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/features/palette/PaletteProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ PaletteProvider.prototype.getPaletteEntries = function(element) {
parent: subProcess
});

create.start(event, [ subProcess, startEvent ]);
create.start(event, [ subProcess, startEvent ], {
hints: {
autoSelect: [ startEvent ]
}
});
}

function createParticipant(event) {
Expand Down
28 changes: 27 additions & 1 deletion test/spec/features/palette/PaletteProviderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import { createMoveEvent } from 'diagram-js/lib/features/mouse/Mouse';

import { is } from 'lib/util/ModelUtil';

import {
createCanvasEvent as canvasEvent
} from '../../../util/MockEvents';

import {
query as domQuery,
queryAll as domQueryAll
Expand Down Expand Up @@ -46,7 +50,7 @@ describe('features/palette', function() {

describe('sub process', function() {

it('should create sub process with start event', inject(function(dragging, palette) {
it('should create sub process with start event', inject(function(dragging) {

// when
triggerPaletteEntry('create.subprocess-expanded');
Expand All @@ -60,6 +64,28 @@ describe('features/palette', function() {
expect(is(elements[1], 'bpmn:StartEvent')).to.be.true;
}));


it('should select start event', inject(function(canvas, dragging, selection) {

// given
var rootElement = canvas.getRootElement(),
rootGfx = canvas.getGraphics(rootElement);

triggerPaletteEntry('create.subprocess-expanded');

// when
dragging.hover({ element: rootElement, gfx: rootGfx });

dragging.move(canvasEvent({ x: 100, y: 100 }));

// when
dragging.end();

// then
expect(selection.get()).to.have.length(1);
expect(is(selection.get()[0], 'bpmn:StartEvent')).to.be.true;
}));

});

});
Expand Down

0 comments on commit 20114ae

Please sign in to comment.