fix(modeling): ensure plane ID change is undoable
related to https://github.com/camunda/camunda-modeler/issues/2750
This commit is contained in:
parent
56d38c76fb
commit
bac7d5e1cd
|
@ -216,7 +216,7 @@ export default function SubProcessPlaneBehavior(
|
|||
this.reverted('element.updateProperties', function(context) {
|
||||
var shape = context.element;
|
||||
|
||||
if (!isCollapsedSubProcess(shape)) {
|
||||
if (!is(shape, 'bpmn:SubProcess')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -230,6 +230,13 @@ export default function SubProcessPlaneBehavior(
|
|||
return;
|
||||
}
|
||||
|
||||
if (isPlane(shape)) {
|
||||
elementRegistry.updateId(shape, toPlaneId(oldId));
|
||||
elementRegistry.updateId(newId, oldId);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var planeElement = elementRegistry.get(toPlaneId(newId));
|
||||
|
||||
if (!planeElement) {
|
||||
|
|
|
@ -305,36 +305,118 @@ describe('features/modeling/behavior - subprocess planes', function() {
|
|||
}));
|
||||
|
||||
|
||||
it('should update plane id when primary shape is changed',
|
||||
inject(function(modeling, elementRegistry) {
|
||||
describe('do', function() {
|
||||
|
||||
// given
|
||||
var subProcess = elementRegistry.get('SubProcess_2'),
|
||||
plane = elementRegistry.get('SubProcess_2_plane');
|
||||
it('should update plane id when primary shape is changed',
|
||||
inject(function(modeling, elementRegistry) {
|
||||
|
||||
// when
|
||||
modeling.updateProperties(subProcess, { id: 'new_name' });
|
||||
// given
|
||||
var subProcess = elementRegistry.get('SubProcess_2'),
|
||||
plane = elementRegistry.get('SubProcess_2_plane');
|
||||
|
||||
// then
|
||||
expect(subProcess.id).to.equal('new_name');
|
||||
expect(plane.id).to.equal('new_name_plane');
|
||||
}));
|
||||
// when
|
||||
modeling.updateProperties(subProcess, { id: 'new_name' });
|
||||
|
||||
// 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) {
|
||||
it('should update primary shape id when plane is changed',
|
||||
inject(function(modeling, elementRegistry) {
|
||||
|
||||
// given
|
||||
var subProcess = elementRegistry.get('SubProcess_2'),
|
||||
plane = elementRegistry.get('SubProcess_2_plane');
|
||||
// given
|
||||
var subProcess = elementRegistry.get('SubProcess_2'),
|
||||
plane = elementRegistry.get('SubProcess_2_plane');
|
||||
|
||||
// when
|
||||
modeling.updateProperties(plane, { id: 'new_name' });
|
||||
// when
|
||||
modeling.updateProperties(plane, { id: 'new_name' });
|
||||
|
||||
// then
|
||||
expect(subProcess.id).to.equal('new_name');
|
||||
expect(plane.id).to.equal('new_name_plane');
|
||||
}));
|
||||
// then
|
||||
expect(subProcess.id).to.equal('new_name');
|
||||
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',
|
||||
|
|
Loading…
Reference in New Issue