parent
7de043ab9d
commit
ec159381ce
|
@ -4,7 +4,9 @@ var assign = require('lodash/object/assign'),
|
||||||
inherits = require('inherits');
|
inherits = require('inherits');
|
||||||
|
|
||||||
var LabelUtil = require('../../../util/LabelUtil'),
|
var LabelUtil = require('../../../util/LabelUtil'),
|
||||||
is = require('../../../util/ModelUtil').is;
|
ModelUtil = require('../../../util/ModelUtil'),
|
||||||
|
is = ModelUtil.is,
|
||||||
|
getBusinessObject = ModelUtil.getBusinessObject;
|
||||||
|
|
||||||
var hasExternalLabel = LabelUtil.hasExternalLabel,
|
var hasExternalLabel = LabelUtil.hasExternalLabel,
|
||||||
getExternalLabelMid = LabelUtil.getExternalLabelMid;
|
getExternalLabelMid = LabelUtil.getExternalLabelMid;
|
||||||
|
@ -68,6 +70,19 @@ function LabelSupport(eventBus, modeling, bpmnFactory) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.postExecute([ 'shape.replace' ], function(e) {
|
||||||
|
var context = e.context,
|
||||||
|
newShape = context.newShape,
|
||||||
|
oldShape = context.oldShape;
|
||||||
|
|
||||||
|
var businessObject = getBusinessObject(newShape);
|
||||||
|
|
||||||
|
if (businessObject && hasExternalLabel(businessObject)) {
|
||||||
|
newShape.label.x = oldShape.label.x;
|
||||||
|
newShape.label.y = oldShape.label.y;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// update di information on label creation
|
// update di information on label creation
|
||||||
this.executed([ 'label.create' ], function(e) {
|
this.executed([ 'label.create' ], function(e) {
|
||||||
|
|
||||||
|
|
|
@ -247,6 +247,25 @@ describe('features/replace - bpmn replace', function() {
|
||||||
expect(newElement.y).to.equal(task.y);
|
expect(newElement.y).to.equal(task.y);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should keep label position', inject(function (elementRegistry, bpmnReplace, modeling) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var exclusiveGateway = elementRegistry.get('ExclusiveGateway_1');
|
||||||
|
var label = elementRegistry.get('ExclusiveGateway_1_label');
|
||||||
|
|
||||||
|
var newElementData = {
|
||||||
|
type: 'bpmn:InclusiveGateway'
|
||||||
|
};
|
||||||
|
|
||||||
|
// when
|
||||||
|
var newElement = bpmnReplace.replaceElement(exclusiveGateway, newElementData);
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(newElement.label.x).to.equal(label.x);
|
||||||
|
expect(newElement.label.y).to.equal(label.y);
|
||||||
|
|
||||||
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue