feat(label-behavior): correctly retrieve label from element
Relates to camunda/camunda-modeler#1417
This commit is contained in:
parent
af348a511e
commit
b7d6d62184
|
@ -15,6 +15,10 @@ import {
|
|||
hasExternalLabel
|
||||
} from '../../../util/LabelUtil';
|
||||
|
||||
import {
|
||||
getLabel
|
||||
} from '../../label-editing/LabelUtil';
|
||||
|
||||
import {
|
||||
getLabelAdjustment
|
||||
} from './util/LabelLayoutUtil';
|
||||
|
@ -105,8 +109,8 @@ export default function LabelBehavior(
|
|||
return;
|
||||
}
|
||||
|
||||
// only create label if name
|
||||
if (!businessObject.name) {
|
||||
// only create label if attribute available
|
||||
if (!getLabel(element)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -115,7 +119,7 @@ export default function LabelBehavior(
|
|||
// we don't care about x and y
|
||||
var labelDimensions = textRenderer.getExternalLabelBounds(
|
||||
DEFAULT_LABEL_DIMENSIONS,
|
||||
businessObject.name || ''
|
||||
getLabel(element)
|
||||
);
|
||||
|
||||
modeling.createLabel(element, labelCenter, {
|
||||
|
|
|
@ -151,6 +151,31 @@ describe('behavior - LabelBehavior', function() {
|
|||
));
|
||||
|
||||
|
||||
it('should add to group', inject(
|
||||
function(bpmnFactory, elementRegistry, modeling) {
|
||||
|
||||
// given
|
||||
var parentShape = elementRegistry.get('Process_1'),
|
||||
categoryValue = bpmnFactory.create('bpmn:CategoryValue', {
|
||||
value: 'foo'
|
||||
}),
|
||||
businessObject = bpmnFactory.create('bpmn:Group', {
|
||||
categoryValueRef: categoryValue
|
||||
}),
|
||||
newShapeAttrs = {
|
||||
type: 'bpmn:Group',
|
||||
businessObject: businessObject
|
||||
};
|
||||
|
||||
// when
|
||||
var newShape = modeling.createShape(newShapeAttrs, { x: 50, y: 50 }, parentShape);
|
||||
|
||||
// then
|
||||
expect(newShape.label).to.exist;
|
||||
}
|
||||
));
|
||||
|
||||
|
||||
it('should not add to task', inject(
|
||||
function(elementFactory, elementRegistry, modeling) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue