mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-02-28 00:20:43 +00:00
fix(drilldown): prevent infinite loop on root property change
related to https://github.com/bpmn-io/bpmn-js-properties-panel/issues/569
This commit is contained in:
parent
069b1902c9
commit
a696aa5953
@ -4,9 +4,7 @@ import { find } from 'min-dash';
|
|||||||
import { escapeHTML } from 'diagram-js/lib/util/EscapeUtil';
|
import { escapeHTML } from 'diagram-js/lib/util/EscapeUtil';
|
||||||
import { getBusinessObject, is } from '../../util/ModelUtil';
|
import { getBusinessObject, is } from '../../util/ModelUtil';
|
||||||
import {
|
import {
|
||||||
getPlaneIdFromShape,
|
getPlaneIdFromShape
|
||||||
getShapeIdFromPlane,
|
|
||||||
isPlane
|
|
||||||
} from '../../util/DrilldownUtil';
|
} from '../../util/DrilldownUtil';
|
||||||
|
|
||||||
var OPEN_CLASS = 'bjs-breadcrumbs-shown';
|
var OPEN_CLASS = 'bjs-breadcrumbs-shown';
|
||||||
@ -28,19 +26,6 @@ export default function DrilldownBreadcrumbs(eventBus, elementRegistry, overlays
|
|||||||
|
|
||||||
var boParents = [];
|
var boParents = [];
|
||||||
|
|
||||||
// update primary shape if name or ID of the plane changes
|
|
||||||
eventBus.on('element.changed', function(e) {
|
|
||||||
var shape = e.element;
|
|
||||||
|
|
||||||
if (!isPlane(shape)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var primary = elementRegistry.get(getShapeIdFromPlane(shape));
|
|
||||||
|
|
||||||
primary && eventBus.fire('element.changed', { element: primary });
|
|
||||||
});
|
|
||||||
|
|
||||||
// update breadcrumbs if name or ID of the primary shape changes
|
// update breadcrumbs if name or ID of the primary shape changes
|
||||||
eventBus.on('element.changed', function(e) {
|
eventBus.on('element.changed', function(e) {
|
||||||
var shape = e.element,
|
var shape = e.element,
|
||||||
|
@ -239,6 +239,27 @@ export default function SubProcessPlaneBehavior(
|
|||||||
elementRegistry.updateId(planeElement, toPlaneId(oldId));
|
elementRegistry.updateId(planeElement, toPlaneId(oldId));
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
// re-throw element.changed to re-render primary shape if associated plane has
|
||||||
|
// changed (e.g. bpmn:name property has changed)
|
||||||
|
eventBus.on('element.changed', function(context) {
|
||||||
|
var element = context.element;
|
||||||
|
|
||||||
|
if (!isPlane(element)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var plane = element;
|
||||||
|
|
||||||
|
var primaryShape = elementRegistry.get(getShapeIdFromPlane(plane));
|
||||||
|
|
||||||
|
// do not re-throw if no associated primary shape (e.g. bpmn:Process)
|
||||||
|
if (!primaryShape || primaryShape === plane) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
eventBus.fire('element.changed', { element: primaryShape });
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// create/remove plane for the subprocess
|
// create/remove plane for the subprocess
|
||||||
this.executed('shape.toggleCollapse', LOW_PRIORITY, function(context) {
|
this.executed('shape.toggleCollapse', LOW_PRIORITY, function(context) {
|
||||||
|
@ -151,6 +151,27 @@ describe('features - drilldown', function() {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
it('should update on process name change',
|
||||||
|
inject(function(canvas, elementRegistry, modeling) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
canvas.setRootElement(canvas.findRoot('collapsedProcess_2_plane'));
|
||||||
|
var shape = elementRegistry.get('rootProcess');
|
||||||
|
|
||||||
|
// when
|
||||||
|
modeling.updateProperties(shape, { name: 'new name' });
|
||||||
|
|
||||||
|
// then
|
||||||
|
expectBreadcrumbs([
|
||||||
|
'new name',
|
||||||
|
'Collapsed Process',
|
||||||
|
'Expanded Process',
|
||||||
|
'Collapsed Process 2'
|
||||||
|
]);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -336,6 +336,27 @@ describe('features/modeling/behavior - subprocess planes', function() {
|
|||||||
expect(plane.id).to.equal('new_name_plane');
|
expect(plane.id).to.equal('new_name_plane');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('should rerender primary shape name when plane is changed',
|
||||||
|
inject(function(modeling, elementRegistry, eventBus) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var subProcess = elementRegistry.get('SubProcess_2'),
|
||||||
|
plane = elementRegistry.get('SubProcess_2_plane');
|
||||||
|
|
||||||
|
var changedSpy = sinon.spy();
|
||||||
|
|
||||||
|
eventBus.on('element.changed', 5000, changedSpy);
|
||||||
|
|
||||||
|
// when
|
||||||
|
modeling.updateProperties(plane, { name: 'new name' });
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(changedSpy).to.have.been.calledTwice;
|
||||||
|
expect(changedSpy.secondCall.args[0].element).to.eql(subProcess);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user