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) {
|
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) {
|
||||||
|
|
|
@ -305,36 +305,118 @@ describe('features/modeling/behavior - subprocess planes', function() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
it('should update plane id when primary shape is changed',
|
describe('do', function() {
|
||||||
inject(function(modeling, elementRegistry) {
|
|
||||||
|
|
||||||
// given
|
it('should update plane id when primary shape is changed',
|
||||||
var subProcess = elementRegistry.get('SubProcess_2'),
|
inject(function(modeling, elementRegistry) {
|
||||||
plane = elementRegistry.get('SubProcess_2_plane');
|
|
||||||
|
|
||||||
// when
|
// given
|
||||||
modeling.updateProperties(subProcess, { id: 'new_name' });
|
var subProcess = elementRegistry.get('SubProcess_2'),
|
||||||
|
plane = elementRegistry.get('SubProcess_2_plane');
|
||||||
|
|
||||||
// then
|
// when
|
||||||
expect(subProcess.id).to.equal('new_name');
|
modeling.updateProperties(subProcess, { id: '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');
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
it('should update primary shape id when plane is changed',
|
it('should update primary shape id when plane is changed',
|
||||||
inject(function(modeling, elementRegistry) {
|
inject(function(modeling, elementRegistry) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
var subProcess = elementRegistry.get('SubProcess_2'),
|
var subProcess = elementRegistry.get('SubProcess_2'),
|
||||||
plane = elementRegistry.get('SubProcess_2_plane');
|
plane = elementRegistry.get('SubProcess_2_plane');
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.updateProperties(plane, { id: 'new_name' });
|
modeling.updateProperties(plane, { id: 'new_name' });
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(subProcess.id).to.equal('new_name');
|
expect(subProcess.id).to.equal('new_name');
|
||||||
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',
|
||||||
|
|
Loading…
Reference in New Issue