Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/dmn-js-drd/src/features/label-editing/LabelUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ export function setLabel(element, text, isExternal) {
var semantic = element.businessObject,
attr = getLabelAttr(semantic);

if (attr) {
if (attr === 'name') {

// name is required by the DMN schema
semantic.name = text || '';
} else if (attr) {
semantic[attr] = text;
}

Expand Down
5 changes: 5 additions & 0 deletions packages/dmn-js-drd/src/features/modeling/ElementFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ ElementFactory.prototype.createDrdElement = function(elementType, attrs) {
}

businessObject = drdFactory.create(attrs.type);

// name is required by the DMN schema
if (is(businessObject, 'dmn:DRGElement') && !businessObject.name) {
businessObject.name = '';
}
}

if (!businessObject.di) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ describe('features - label-editing', function() {
directEdit('dish-decision', ' ');

// then
expect(getBusinessObject(decision).name).not.to.exist;
// name is required by the DMN schema
expect(getBusinessObject(decision).name).to.equal('');
});

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,46 @@ describe('features/modeling - create elements', function() {
expect(di.$type).to.eql('dmndi:DMNEdge');
expect(di.id).to.match(/DMNEdge_/);
}));


// name is required by the DMN schema
forEach([
'dmn:Decision',
'dmn:BusinessKnowledgeModel',
'dmn:InputData',
'dmn:KnowledgeSource'
], function(type) {

it('should create ' + type + ' with empty name', inject(
function(elementFactory) {

// when
var shape = elementFactory.createShape({ type: type });

// then
expect(shape.businessObject.name).to.equal('');
}
));

});


it('should keep given name', inject(function(drdFactory, elementFactory) {

// given
var businessObject = drdFactory.create('dmn:Decision', {
name: 'Season'
});

// when
var decision = elementFactory.createShape({
type: 'dmn:Decision',
businessObject: businessObject
});

// then
expect(decision.businessObject.name).to.equal('Season');
}));
});


Expand Down