Merge master to develop

This commit is contained in:
bpmn-io-bot 2022-01-19 08:20:34 +00:00
commit 2ae21c3c57
6 changed files with 64 additions and 1 deletions

View File

@ -145,6 +145,7 @@ export default function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy) {
); );
newDi = bpmnFactory.create(oldDi.$type); newDi = bpmnFactory.create(oldDi.$type);
newDi.bpmnElement = newBusinessObject;
descriptor.di = moddleCopy.copyElement( descriptor.di = moddleCopy.copyElement(
oldDi, oldDi,

View File

@ -42,6 +42,10 @@ BpmnFactory.prototype._needsId = function(element) {
}; };
BpmnFactory.prototype._ensureId = function(element) { BpmnFactory.prototype._ensureId = function(element) {
if (element.id) {
this._model.ids.claim(element.id, element);
return;
}
// generate semantic ids for elements // generate semantic ids for elements
// bpmn:SequenceFlow -> SequenceFlow_ID // bpmn:SequenceFlow -> SequenceFlow_ID

View File

@ -47,7 +47,9 @@ export default function UnclaimIdBehavior(canvas, injector, moddle, modeling) {
var rootElement = canvas.getRootElement(), var rootElement = canvas.getRootElement(),
rootElementBo = rootElement.businessObject; rootElementBo = rootElement.businessObject;
moddle.ids.unclaim(rootElementBo.id); if (is(rootElement, 'bpmn:Collaboration')) {
moddle.ids.unclaim(rootElementBo.id);
}
}); });
} }

View File

@ -463,6 +463,35 @@ describe('features/copy-paste', function() {
} }
)); ));
it('should wire DIs correctly', inject(
function(canvas, copyPaste, elementRegistry) {
// given
var subprcoess = elementRegistry.get('SubProcess_1'),
rootElement = canvas.getRootElement();
copyPaste.copy(subprcoess);
// when
var elements = copyPaste.paste({
element: rootElement,
point: {
x: 300,
y: 300
}
});
// then
var subprocess = elements[0];
var di = subprocess.di;
expect(di).to.exist;
expect(di.bpmnElement).to.exist;
expect(di.bpmnElement).to.equal(subprocess.businessObject);
}
));
}); });

View File

@ -116,6 +116,16 @@ describe('features - bpmn-factory', function() {
}) })
); );
}); });
it('should claim provided id', inject(function(bpmnFactory, moddle) {
var task = bpmnFactory.create('bpmn:Task', { id: 'foo' });
expect(task).to.exist;
expect(task.id).to.eql('foo');
expect(moddle.ids.assigned('foo')).to.exist;
}));
}); });

View File

@ -82,4 +82,21 @@ describe('features/modeling - unclaim id', function() {
expect(moddle.ids.assigned('Collaboration_1')).to.be.false; expect(moddle.ids.assigned('Collaboration_1')).to.be.false;
})); }));
describe('morphing', function() {
var simpleXML = require('../../../../fixtures/bpmn/simple.bpmn');
beforeEach(bootstrapModeler(simpleXML, { modules: testModules }));
it('should keep ID of root', inject(function(moddle, modeling) {
// when
modeling.makeCollaboration();
// then
expect(moddle.ids.assigned('Process_1')).to.exist;
}));
});
}); });