fix(modeling): correct DI updating

Don't assign <di> property to businessObject; will
be serialized as di="[Object...]" otherwise.

Closes #756
This commit is contained in:
Nico Rehwaldt 2018-01-31 12:15:32 +01:00
parent 3124f9ba96
commit cbb2f9f600
2 changed files with 30 additions and 9 deletions

View File

@ -98,10 +98,6 @@ UpdatePropertiesHandler.prototype.execute = function(context) {
element.label.hidden = !properties[NAME];
}
if (DI in properties && businessObject.di) {
setDiProperties(businessObject.di, properties.di);
}
// update properties
setProperties(businessObject, properties);
@ -147,10 +143,6 @@ UpdatePropertiesHandler.prototype.revert = function(context) {
elementRegistry = this._elementRegistry,
ids = this._moddle.ids;
if (DI in oldProperties && businessObject.di) {
setDiProperties(businessObject.di, oldProperties.di);
}
// update properties
setProperties(businessObject, oldProperties);
@ -199,7 +191,15 @@ function getDiProperties(di, propertyNames) {
function setProperties(businessObject, properties) {
forEach(properties, function(value, key) {
businessObject.set(key, value);
if (key !== DI) {
businessObject.set(key, value);
} else {
// only update, if businessObject.id exists
if (businessObject.di) {
setDiProperties(businessObject.di, value);
}
}
});
}

View File

@ -270,6 +270,8 @@ describe('features/modeling - update properties', function() {
// then
expect(flowBo.di.fill).to.equal('FUCHSIA');
expect(flowBo.get('di')).not.to.exist;
}));
@ -578,6 +580,25 @@ describe('features/modeling - update properties', function() {
}
));
it('should ignore setting color on root', inject(
function(canvas, modeling) {
// given
var rootElement = canvas.getRootElement();
// when
modeling.updateProperties(rootElement, {
di: {
fill: 'fuchsia'
}
});
// then
expect(rootElement.di).not.to.exist;
}
));
});
});