fix(BpmnLabelSupport): fix hidden property assignment

Closes #401
This commit is contained in:
Ricardo Matias 2016-01-04 11:12:53 +01:00 committed by Nico Rehwaldt
parent 35564d1bea
commit d344e679fd
3 changed files with 24 additions and 3 deletions

View File

@ -28,9 +28,10 @@ function LabelSupport(eventBus, modeling, bpmnFactory) {
if (hasExternalLabel(businessObject)) {
position = getExternalLabelMid(element);
modeling.createLabel(element, position, {
id: businessObject.id + '_label',
hidden: true,
hidden: !businessObject.name,
businessObject: businessObject
});
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn">
<bpmn:process id="Process_1" isExecutable="false">
<bpmn:startEvent id="StartEvent_1">
<bpmn:startEvent id="StartEvent_1" name="KEEP ME">
<bpmn:outgoing>SequenceFlow_1</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:task id="Task_1" name="Task Caption">

View File

@ -245,7 +245,7 @@ describe('features/replace', function() {
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
it('should keep copy label',
it('should keep interior labels',
inject(function(elementRegistry, bpmnReplace) {
// given
@ -262,6 +262,26 @@ describe('features/replace', function() {
expect(newElement.businessObject.name).to.equal('Task Caption');
}));
it('should keep exterior labels',
inject(function(elementRegistry, bpmnReplace) {
// given
var startEvent = elementRegistry.get('StartEvent_1');
var newElementData = {
type: 'bpmn:EndEvent'
};
// when
var newElement = bpmnReplace.replaceElement(startEvent, newElementData);
// then
expect(newElement.label.hidden).to.equal(false);
expect(newElement.label.labelTarget).to.equal(newElement);
expect(newElement.businessObject.name).to.equal('KEEP ME');
}));
});