fix(modeling): ensure plane ID change is undoable

related to https://github.com/camunda/camunda-modeler/issues/2750
This commit is contained in:
Martin Stamm 2022-02-14 14:20:29 +01:00 committed by fake-join[bot]
parent 56d38c76fb
commit bac7d5e1cd
2 changed files with 112 additions and 23 deletions

View File

@ -216,7 +216,7 @@ export default function SubProcessPlaneBehavior(
this.reverted('element.updateProperties', function(context) { this.reverted('element.updateProperties', function(context) {
var shape = context.element; var shape = context.element;
if (!isCollapsedSubProcess(shape)) { if (!is(shape, 'bpmn:SubProcess')) {
return; return;
} }
@ -230,6 +230,13 @@ export default function SubProcessPlaneBehavior(
return; return;
} }
if (isPlane(shape)) {
elementRegistry.updateId(shape, toPlaneId(oldId));
elementRegistry.updateId(newId, oldId);
return;
}
var planeElement = elementRegistry.get(toPlaneId(newId)); var planeElement = elementRegistry.get(toPlaneId(newId));
if (!planeElement) { if (!planeElement) {

View File

@ -305,6 +305,8 @@ describe('features/modeling/behavior - subprocess planes', function() {
})); }));
describe('do', function() {
it('should update plane id when primary shape is changed', it('should update plane id when primary shape is changed',
inject(function(modeling, elementRegistry) { inject(function(modeling, elementRegistry) {
@ -336,6 +338,86 @@ describe('features/modeling/behavior - subprocess planes', function() {
expect(plane.id).to.equal('new_name_plane'); expect(plane.id).to.equal('new_name_plane');
})); }));
});
describe('undo', function() {
it('should update plane id when primary shape is changed',
inject(function(modeling, elementRegistry, commandStack) {
// given
var subProcess = elementRegistry.get('SubProcess_2'),
plane = elementRegistry.get('SubProcess_2_plane');
// when
modeling.updateProperties(subProcess, { id: 'new_name' });
commandStack.undo();
// then
expect(subProcess.id).to.equal('SubProcess_2');
expect(plane.id).to.equal('SubProcess_2_plane');
}));
it('should update primary shape id when plane is changed',
inject(function(modeling, elementRegistry, commandStack) {
// given
var subProcess = elementRegistry.get('SubProcess_2'),
plane = elementRegistry.get('SubProcess_2_plane');
// when
modeling.updateProperties(plane, { id: 'new_name' });
commandStack.undo();
// then
expect(subProcess.id).to.equal('SubProcess_2');
expect(plane.id).to.equal('SubProcess_2_plane');
}));
});
describe('redo', function() {
it('should update plane id when primary shape is changed',
inject(function(modeling, elementRegistry, commandStack) {
// given
var subProcess = elementRegistry.get('SubProcess_2'),
plane = elementRegistry.get('SubProcess_2_plane');
// when
modeling.updateProperties(subProcess, { id: 'new_name' });
commandStack.undo();
commandStack.redo();
// then
expect(subProcess.id).to.equal('new_name');
expect(plane.id).to.equal('new_name_plane');
}));
it('should update primary shape id when plane is changed',
inject(function(modeling, elementRegistry, commandStack) {
// given
var subProcess = elementRegistry.get('SubProcess_2'),
plane = elementRegistry.get('SubProcess_2_plane');
// when
modeling.updateProperties(plane, { id: 'new_name' });
commandStack.undo();
commandStack.redo();
// then
expect(subProcess.id).to.equal('new_name');
expect(plane.id).to.equal('new_name_plane');
}));
});
it('should rerender primary shape name when plane is changed', it('should rerender primary shape name when plane is changed',
inject(function(modeling, elementRegistry, eventBus) { inject(function(modeling, elementRegistry, eventBus) {