mirror of
https://github.com/bpmn-io/bpmn-js.git
synced 2025-08-26 12:40:20 +08:00
fix(morphing): release id on element replace
Closes camunda/camunda-modeler#97
This commit is contained in:

committed by
pedesen

parent
bc53dc98db
commit
07a1ef29b6
@ -57,6 +57,9 @@ function ReplaceElementBehaviour(eventBus, bpmnReplace, bpmnRules, elementRegist
|
|||||||
attachers = oldShape.attachers,
|
attachers = oldShape.attachers,
|
||||||
canReplace;
|
canReplace;
|
||||||
|
|
||||||
|
modeling.unclaimId(oldShape.businessObject.id, oldShape.businessObject);
|
||||||
|
modeling.claimId(newShape.businessObject.id, newShape.businessObject);
|
||||||
|
|
||||||
if (attachers && attachers.length) {
|
if (attachers && attachers.length) {
|
||||||
canReplace = bpmnRules.canReplace(attachers, newShape);
|
canReplace = bpmnRules.canReplace(attachers, newShape);
|
||||||
|
|
||||||
|
@ -62,7 +62,6 @@ describe('features/modeling - move start event behavior', function() {
|
|||||||
// then
|
// then
|
||||||
expect(selection.get()).to.include(replacement);
|
expect(selection.get()).to.include(replacement);
|
||||||
expect(selection.get()).not.to.include(startEvent);
|
expect(selection.get()).not.to.include(startEvent);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
@ -104,6 +103,43 @@ describe('features/modeling - move start event behavior', function() {
|
|||||||
|
|
||||||
describe('- normal -', 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',
|
it('should replace CancelEvent when morphing transaction',
|
||||||
inject(function(elementRegistry, bpmnReplace) {
|
inject(function(elementRegistry, bpmnReplace) {
|
||||||
// given
|
// given
|
||||||
|
Reference in New Issue
Block a user