Merge branch 'master' into develop
This commit is contained in:
commit
96255cdd96
|
@ -220,9 +220,9 @@ ModdleCopy.prototype.copyProperty = function(property, parent, propertyName) {
|
|||
return;
|
||||
}
|
||||
|
||||
// disallow copying IDs if already assigned
|
||||
if (propertyDescriptor.isId && this._moddle.ids.assigned(property)) {
|
||||
return;
|
||||
// copy id
|
||||
if (propertyDescriptor.isId) {
|
||||
return this._copyId(property, parent);
|
||||
}
|
||||
|
||||
// copy arrays
|
||||
|
@ -263,6 +263,18 @@ ModdleCopy.prototype.copyProperty = function(property, parent, propertyName) {
|
|||
return property;
|
||||
};
|
||||
|
||||
ModdleCopy.prototype._copyId = function(id, element) {
|
||||
|
||||
// disallow if already taken
|
||||
if (this._moddle.ids.assigned(id)) {
|
||||
return;
|
||||
} else {
|
||||
|
||||
this._moddle.ids.claim(id, element);
|
||||
return id;
|
||||
}
|
||||
};
|
||||
|
||||
// helpers //////////
|
||||
|
||||
export function getPropertyNames(descriptor, keepDefaultProperties) {
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1q7lgbo" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.11.1" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.151.0">
|
||||
<bpmn:process id="Process_1" isExecutable="true">
|
||||
<bpmn:startEvent id="A" name="A" />
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
|
||||
<bpmndi:BPMNShape id="Event_083mmcb_di" bpmnElement="A">
|
||||
<dc:Bounds x="152" y="82" width="36" height="36" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="167" y="125" width="7" height="14" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1q7lgbo" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.11.1" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.151.0">
|
||||
<bpmn:process id="Process_1" isExecutable="true">
|
||||
<bpmn:startEvent id="B" name="B" />
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
|
||||
<bpmndi:BPMNShape id="Event_083mmcb_di" bpmnElement="B">
|
||||
<dc:Bounds x="102" y="82" width="36" height="36" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="117" y="125" width="7" height="14" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
|
@ -2,10 +2,12 @@ import Modeler from 'lib/Modeler';
|
|||
import Viewer from 'lib/Viewer';
|
||||
import NavigatedViewer from 'lib/NavigatedViewer';
|
||||
|
||||
import Clipboard from 'diagram-js/lib/features/clipboard/Clipboard';
|
||||
|
||||
import TestContainer from 'mocha-test-container-support';
|
||||
|
||||
import {
|
||||
createEvent
|
||||
createCanvasEvent
|
||||
} from '../util/MockEvents';
|
||||
|
||||
import {
|
||||
|
@ -306,19 +308,18 @@ describe('Modeler', function() {
|
|||
// given
|
||||
var bendpointMove = modeler.get('bendpointMove'),
|
||||
dragging = modeler.get('dragging'),
|
||||
elementRegistry = modeler.get('elementRegistry'),
|
||||
canvas = modeler.get('canvas');
|
||||
elementRegistry = modeler.get('elementRegistry');
|
||||
|
||||
// assume
|
||||
expect(bendpointMove).to.exist;
|
||||
|
||||
// when
|
||||
bendpointMove.start(
|
||||
createEvent(canvas, { x: 0, y: 0 }),
|
||||
createCanvasEvent({ x: 0, y: 0 }),
|
||||
elementRegistry.get('SequenceFlow_1'),
|
||||
1
|
||||
);
|
||||
dragging.move(createEvent(canvas, { x: 200, y: 200 }));
|
||||
dragging.move(createCanvasEvent({ x: 200, y: 200 }));
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -567,6 +568,7 @@ describe('Modeler', function() {
|
|||
|
||||
});
|
||||
|
||||
|
||||
it('should inject mandatory modules', function() {
|
||||
|
||||
// given
|
||||
|
@ -611,6 +613,101 @@ describe('Modeler', function() {
|
|||
});
|
||||
|
||||
|
||||
describe('copy and paste', function() {
|
||||
|
||||
var m1, m2;
|
||||
|
||||
afterEach(function() {
|
||||
if (m1) {
|
||||
m1.destroy();
|
||||
}
|
||||
|
||||
if (m2) {
|
||||
m2.destroy();
|
||||
}
|
||||
});
|
||||
|
||||
function isNamedA(element) {
|
||||
return element.type !== 'label' && element.businessObject.name === 'A';
|
||||
}
|
||||
|
||||
|
||||
it('should share Clipboard', function() {
|
||||
|
||||
var aXML = require('./Modeler.copy-paste.a.bpmn');
|
||||
var bXML = require('./Modeler.copy-paste.b.bpmn');
|
||||
|
||||
var clipboardModule = {
|
||||
'clipboard': [ 'value', new Clipboard() ]
|
||||
};
|
||||
|
||||
m2 = new Modeler({
|
||||
container: container,
|
||||
additionalModules: [
|
||||
clipboardModule
|
||||
]
|
||||
});
|
||||
|
||||
m1 = new Modeler({
|
||||
container: container,
|
||||
additionalModules: [
|
||||
clipboardModule
|
||||
]
|
||||
});
|
||||
|
||||
return Promise.all([
|
||||
m1.importXML(aXML),
|
||||
m2.importXML(bXML)
|
||||
]).then(function() {
|
||||
|
||||
// given
|
||||
// copy element <A> from m1
|
||||
m1.invoke(function(selection, elementRegistry, editorActions) {
|
||||
selection.select(elementRegistry.get('A'));
|
||||
|
||||
editorActions.trigger('copy');
|
||||
});
|
||||
|
||||
// TODO(nikku): needed for our canvas utilities to work
|
||||
setBpmnJS(m2);
|
||||
|
||||
m2.invoke(function(dragging, editorActions, elementRegistry) {
|
||||
|
||||
var processElement = elementRegistry.get('Process_1');
|
||||
|
||||
// when
|
||||
// paste element <A> to m2, first try
|
||||
editorActions.trigger('paste');
|
||||
dragging.move(createCanvasEvent({ x: 150, y: 150 }));
|
||||
dragging.move(createCanvasEvent({ x: 170, y: 150 }));
|
||||
dragging.hover({ element: processElement });
|
||||
|
||||
dragging.end();
|
||||
|
||||
// then
|
||||
expect(elementRegistry.get('A')).to.exist;
|
||||
expect(elementRegistry.filter(isNamedA)).to.have.lengthOf(1);
|
||||
|
||||
// but when
|
||||
// paste element <A> to m2, second try
|
||||
editorActions.trigger('paste');
|
||||
dragging.move(createCanvasEvent({ x: 150, y: 150 }));
|
||||
dragging.move(createCanvasEvent({ x: 300, y: 150 }));
|
||||
dragging.hover({ element: processElement });
|
||||
|
||||
dragging.end();
|
||||
|
||||
// then
|
||||
expect(elementRegistry.filter(isNamedA)).to.have.lengthOf(2);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
it('should expose Viewer and NavigatedViewer', function() {
|
||||
expect(Modeler.Viewer).to.equal(Viewer);
|
||||
expect(Modeler.NavigatedViewer).to.equal(NavigatedViewer);
|
||||
|
|
|
@ -13,7 +13,7 @@ import {
|
|||
* specified canvas local coordinates.
|
||||
*
|
||||
* @param {Point} point of the event local the canvas (closure)
|
||||
* @param {Object} data
|
||||
* @param {Object} [data]
|
||||
*
|
||||
* @return {Event} event, scoped to the given canvas
|
||||
*/
|
||||
|
@ -34,7 +34,15 @@ export function createCanvasEvent(position, data) {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an Event
|
||||
*
|
||||
* @param {Element} target
|
||||
* @param { { x: number, y: number } } position
|
||||
* @param {any} [data]
|
||||
*
|
||||
* @return {Event}
|
||||
*/
|
||||
export function createEvent(target, position, data) {
|
||||
|
||||
return getBpmnJS().invoke(function(eventBus) {
|
||||
|
|
Loading…
Reference in New Issue