chore(label-editing): remove businessObject name on empty text

The following two actions will now unset the
business objects name property:

* deleting external label
* entering empty text via direct editing
This commit is contained in:
Nico Rehwaldt 2018-06-08 16:13:18 +02:00 committed by Philipp Fromme
parent a7a1743df0
commit 6c081d854f
4 changed files with 42 additions and 2 deletions

View File

@ -370,6 +370,10 @@ LabelEditingProvider.prototype.update = function(
}; };
} }
if (isEmptyText(newLabel)) {
newLabel = null;
}
this._modeling.updateLabel(element, newLabel, newBounds); this._modeling.updateLabel(element, newLabel, newBounds);
}; };
@ -392,3 +396,7 @@ function isCollapsedPool(element) {
function isExpandedPool(element) { function isExpandedPool(element) {
return is(element, 'bpmn:Participant') && isExpanded(element); return is(element, 'bpmn:Participant') && isExpanded(element);
} }
function isEmptyText(label) {
return !label || !label.trim();
}

View File

@ -94,7 +94,7 @@ export default function LabelBehavior(
// check if label // check if label
if (labelTarget && hints.unsetLabel !== false) { if (labelTarget && hints.unsetLabel !== false) {
modeling.updateLabel(labelTarget, '', null, { removeShape: false }); modeling.updateLabel(labelTarget, null, null, { removeShape: false });
} }
}); });

View File

@ -244,6 +244,38 @@ describe('features - label-editing', function() {
}); });
describe('should unset', function() {
it('name on empty text', function() {
// given
var diagramElement = elementRegistry.get('SequenceFlow_1');
// when
directEditActivate(diagramElement);
directEditComplete(' ');
// then
expect(diagramElement.businessObject.name).not.to.exist;
});
it('text on empty text', function() {
// given
var diagramElement = elementRegistry.get('TextAnnotation_1');
// when
directEditActivate(diagramElement);
directEditComplete(' ');
// then
expect(diagramElement.businessObject.text).not.to.exist;
});
});
describe('should trigger redraw', function() { describe('should trigger redraw', function() {
it('on shape change', function() { it('on shape change', function() {

View File

@ -328,7 +328,7 @@ describe('behavior - LabelBehavior', function() {
// then // then
expect(startEventShape.label).not.to.exist; expect(startEventShape.label).not.to.exist;
expect(startEvent.name).to.equal(''); expect(startEvent.name).not.to.exist;
})); }));
}); });