fix(morphing): release id on element replace
Closes camunda/camunda-modeler#97
This commit is contained in:
parent
bc53dc98db
commit
07a1ef29b6
|
@ -57,6 +57,9 @@ function ReplaceElementBehaviour(eventBus, bpmnReplace, bpmnRules, elementRegist
|
|||
attachers = oldShape.attachers,
|
||||
canReplace;
|
||||
|
||||
modeling.unclaimId(oldShape.businessObject.id, oldShape.businessObject);
|
||||
modeling.claimId(newShape.businessObject.id, newShape.businessObject);
|
||||
|
||||
if (attachers && attachers.length) {
|
||||
canReplace = bpmnRules.canReplace(attachers, newShape);
|
||||
|
||||
|
|
|
@ -62,7 +62,6 @@ describe('features/modeling - move start event behavior', function() {
|
|||
// then
|
||||
expect(selection.get()).to.include(replacement);
|
||||
expect(selection.get()).not.to.include(startEvent);
|
||||
|
||||
}));
|
||||
|
||||
|
||||
|
@ -104,6 +103,43 @@ describe('features/modeling - move start event behavior', function() {
|
|||
|
||||
describe('- normal -', function() {
|
||||
|
||||
|
||||
it('should unclaim old element ID and claim new ID',
|
||||
inject(function(elementRegistry, bpmnReplace) {
|
||||
|
||||
// given
|
||||
var transaction = elementRegistry.get('Transaction_1');
|
||||
|
||||
var ids = transaction.businessObject.$model.ids;
|
||||
|
||||
// when
|
||||
var subProcess = bpmnReplace.replaceElement(transaction, { type: 'bpmn:SubProcess' });
|
||||
|
||||
// then
|
||||
expect(ids.assigned(transaction.id)).to.be.false;
|
||||
expect(ids.assigned(subProcess.id)).to.eql(subProcess.businessObject);
|
||||
}));
|
||||
|
||||
|
||||
it('should REVERT unclaim old element ID and claim new ID on UNDO',
|
||||
inject(function(elementRegistry, bpmnReplace, commandStack) {
|
||||
|
||||
// given
|
||||
var transaction = elementRegistry.get('Transaction_1');
|
||||
|
||||
var ids = transaction.businessObject.$model.ids;
|
||||
|
||||
var subProcess = bpmnReplace.replaceElement(transaction, { type: 'bpmn:SubProcess' });
|
||||
|
||||
// when
|
||||
commandStack.undo();
|
||||
|
||||
// then
|
||||
expect(ids.assigned(transaction.id)).to.eql(transaction.businessObject);
|
||||
expect(ids.assigned(subProcess.id)).to.be.false;
|
||||
}));
|
||||
|
||||
|
||||
it('should replace CancelEvent when morphing transaction',
|
||||
inject(function(elementRegistry, bpmnReplace) {
|
||||
// given
|
||||
|
|
Loading…
Reference in New Issue