Skip to content

Commit 97b15f4

Browse files
committed
feat: allow to create child elements from the context pad
The intention of the pad is to make create simpler, there is no need to carry "should not be child element" restrictions around. Closes #2391
1 parent 87a4516 commit 97b15f4

File tree

2 files changed

+42
-14
lines changed

2 files changed

+42
-14
lines changed

lib/features/rules/BpmnRules.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,6 @@ function nonExistingOrLabel(element) {
271271
return !element || isLabel(element);
272272
}
273273

274-
function isSame(a, b) {
275-
return a === b;
276-
}
277-
278274
/**
279275
* @param {Element} element
280276
*
@@ -967,16 +963,6 @@ function canCreate(shape, target, source, position) {
967963
return true;
968964
}
969965

970-
if (isSame(source, target)) {
971-
return false;
972-
}
973-
974-
// ensure we do not drop the element
975-
// into source
976-
if (source && isParent(source, target)) {
977-
return false;
978-
}
979-
980966
return canDrop(shape, target, position) || canInsert(shape, target, position);
981967
}
982968

test/spec/features/context-pad/ContextPadProviderSpec.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,48 @@ describe('features - context-pad', function() {
482482
})
483483
);
484484

485+
486+
describe('drop onto sub-process', function() {
487+
488+
var basicTests = [
489+
{ action: 'append.append-task', expectedElement: 'bpmn:Task' },
490+
{ action: 'append.intermediate-event', expectedElement: 'bpmn:IntermediateThrowEvent', iit: it.only }
491+
];
492+
493+
494+
for (const { action, expectedElement, iit = it } of basicTests) {
495+
496+
iit(`should create ${expectedElement}`, inject(function(dragging, contextPad, elementRegistry) {
497+
498+
// given
499+
var subProcess = elementRegistry.get('SubProcess_1');
500+
501+
// when
502+
contextPad.open(subProcess);
503+
504+
contextPad.trigger('dragstart', padEvent(action));
505+
506+
dragging.move(canvasEvent({ x: subProcess.x, y: subProcess.y }));
507+
dragging.hover({ element: subProcess });
508+
dragging.move(canvasEvent({ x: subProcess.x + 200, y: subProcess.y + 70 }));
509+
dragging.end();
510+
511+
// then
512+
// find new, unnamed element
513+
var newElement = subProcess.children.find(element => {
514+
return (
515+
is(element, expectedElement) &&
516+
!element.businessObject.name
517+
);
518+
});
519+
520+
expect(newElement, `element of type ${expectedElement}`).to.exist;
521+
}));
522+
523+
}
524+
525+
});
526+
485527
});
486528

487529

0 commit comments

Comments
 (0)