fix(label-behavior): properly check for name property change
Related to camunda/camunda-modeler#824
This commit is contained in:
parent
a3a597f34b
commit
4a0f6da814
|
@ -48,8 +48,8 @@ export default function LabelBehavior(
|
|||
element = context.element,
|
||||
properties = context.properties;
|
||||
|
||||
if (name in properties) {
|
||||
modeling.updateLabel(element, name);
|
||||
if ('name' in properties) {
|
||||
modeling.updateLabel(element, properties.name);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
<?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:dc="http://www.omg.org/spec/DD/20100524/DC" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.14.0">
|
||||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.15.1">
|
||||
<bpmn:process id="Process_1" isExecutable="false">
|
||||
<bpmn:startEvent id="StartEvent_1" name="foo" />
|
||||
<bpmn:task id="Task_1" />
|
||||
<bpmn:exclusiveGateway id="ExclusiveGateway_1" />
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
|
||||
|
@ -15,6 +16,9 @@
|
|||
<bpmndi:BPMNShape id="Task_1_di" bpmnElement="Task_1">
|
||||
<dc:Bounds x="353" y="80" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="ExclusiveGateway_1gzwevj_di" bpmnElement="ExclusiveGateway_1" isMarkerVisible="true">
|
||||
<dc:Bounds x="256" y="95" width="50" height="50" />
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* global sinon */
|
||||
|
||||
import {
|
||||
bootstrapModeler,
|
||||
inject
|
||||
|
@ -17,6 +19,51 @@ describe('behavior - LabelBehavior', function() {
|
|||
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
||||
|
||||
|
||||
describe('updating name property', function() {
|
||||
|
||||
it('should update label', inject(function(elementRegistry, eventBus, modeling) {
|
||||
|
||||
// given
|
||||
var startEvent = elementRegistry.get('StartEvent_1'),
|
||||
spy = sinon.spy();
|
||||
|
||||
eventBus.once('commandStack.element.updateLabel.execute', spy);
|
||||
|
||||
// when
|
||||
modeling.updateProperties(startEvent, {
|
||||
name: 'bar'
|
||||
});
|
||||
|
||||
// then
|
||||
expect(startEvent.businessObject.name).to.equal('bar');
|
||||
expect(spy).to.have.been.called;
|
||||
}));
|
||||
|
||||
|
||||
it('should create label', inject(function(elementRegistry, eventBus, modeling) {
|
||||
|
||||
// given
|
||||
var startEvent = elementRegistry.get('ExclusiveGateway_1'),
|
||||
spy = sinon.spy();
|
||||
|
||||
eventBus.once('commandStack.element.updateLabel.execute', spy);
|
||||
|
||||
// when
|
||||
modeling.updateProperties(startEvent, {
|
||||
name: 'foo'
|
||||
});
|
||||
|
||||
// then
|
||||
var labelShape = startEvent.label;
|
||||
|
||||
expect(labelShape).to.exist;
|
||||
expect(startEvent.businessObject.name).to.equal('foo');
|
||||
expect(spy).to.have.been.called;
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe('add label', function() {
|
||||
|
||||
it('should add to sequence flow with name', inject(
|
||||
|
|
Loading…
Reference in New Issue