fix(modeling): update id property in diagram-js, too
This fixes a bug where updating the id property of an element was not propagated to the diagram. Thus, retrieving the element based on the new id from diagram-js did not work. Closes #238
This commit is contained in:
parent
701bae6c1f
commit
2e73f5ab85
|
@ -5,7 +5,8 @@ var assign = require('lodash/object/assign'),
|
|||
keys = require('lodash/object/keys');
|
||||
|
||||
var DEFAULT_FLOW = 'default',
|
||||
NAME = 'name';
|
||||
NAME = 'name',
|
||||
ID = 'id';
|
||||
|
||||
|
||||
/**
|
||||
|
@ -53,6 +54,10 @@ UpdatePropertiesHandler.prototype.execute = function(context) {
|
|||
properties = context.properties,
|
||||
oldProperties = context.oldProperties || pick(businessObject, keys(properties));
|
||||
|
||||
if (ID in properties) {
|
||||
elementRegistry.updateId(element, properties[ID]);
|
||||
}
|
||||
|
||||
// correctly indicate visual changes on default flow updates
|
||||
if (DEFAULT_FLOW in properties) {
|
||||
|
||||
|
@ -91,9 +96,15 @@ UpdatePropertiesHandler.prototype.execute = function(context) {
|
|||
UpdatePropertiesHandler.prototype.revert = function(context) {
|
||||
|
||||
var element = context.element,
|
||||
businessObject = element.businessObject;
|
||||
oldProperties = context.oldProperties,
|
||||
businessObject = element.businessObject,
|
||||
elementRegistry = this._elementRegistry;
|
||||
|
||||
assign(businessObject, context.oldProperties);
|
||||
|
||||
if (ID in oldProperties) {
|
||||
elementRegistry.updateId(element, oldProperties[ID]);
|
||||
}
|
||||
|
||||
return context.changed;
|
||||
};
|
|
@ -85,6 +85,20 @@ describe('features/modeling - update properties', function() {
|
|||
expect(updatedElements).toContain(elementRegistry.get('SequenceFlow_1_label'));
|
||||
}));
|
||||
|
||||
|
||||
it('updating id', inject(function(elementRegistry, modeling) {
|
||||
|
||||
// given
|
||||
var flowConnection = elementRegistry.get('SequenceFlow_1');
|
||||
|
||||
// when
|
||||
modeling.updateProperties(flowConnection, { id: 'FOO_BAR' });
|
||||
|
||||
// then
|
||||
expect(flowConnection.businessObject.id).toBe('FOO_BAR');
|
||||
expect(flowConnection.id).toBe('FOO_BAR');
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
@ -139,6 +153,21 @@ describe('features/modeling - update properties', function() {
|
|||
expect(updatedElements).toContain(elementRegistry.get('SequenceFlow_1_label'));
|
||||
}));
|
||||
|
||||
|
||||
it('updating id', inject(function(elementRegistry, commandStack, modeling) {
|
||||
|
||||
// given
|
||||
var flowConnection = elementRegistry.get('SequenceFlow_1');
|
||||
|
||||
// when
|
||||
modeling.updateProperties(flowConnection, { id: 'FOO_BAR' });
|
||||
commandStack.undo();
|
||||
|
||||
// then
|
||||
expect(flowConnection.businessObject.id).toBe('SequenceFlow_1');
|
||||
expect(flowConnection.id).toBe('SequenceFlow_1');
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue