mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-02-02 12:13:42 +00:00
Merge branch 'master' into develop
This commit is contained in:
commit
ef5a72d722
@ -1,33 +1,56 @@
|
||||
import {
|
||||
forEach
|
||||
} from 'min-dash';
|
||||
|
||||
import inherits from 'inherits';
|
||||
|
||||
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
||||
|
||||
import { is } from '../../../util/ModelUtil';
|
||||
import { isExpanded } from '../../../util/DiUtil';
|
||||
import { isLabel } from '../../../util/LabelUtil';
|
||||
|
||||
|
||||
/**
|
||||
* Unclaims model IDs on element deletion.
|
||||
*
|
||||
* @param {EventBus} eventBus
|
||||
* @param {Canvas} canvas
|
||||
* @param {Injector} injector
|
||||
* @param {Moddle} moddle
|
||||
* @param {Modeling} modeling
|
||||
*/
|
||||
export default function UnclaimIdBehavior(eventBus, modeling) {
|
||||
export default function UnclaimIdBehavior(canvas, injector, moddle, modeling) {
|
||||
injector.invoke(CommandInterceptor, this);
|
||||
|
||||
CommandInterceptor.call(this, eventBus);
|
||||
|
||||
this.preExecute('elements.delete', function(event) {
|
||||
this.preExecute('shape.delete', function(event) {
|
||||
var context = event.context,
|
||||
elements = context.elements;
|
||||
shape = context.shape,
|
||||
shapeBo = shape.businessObject;
|
||||
|
||||
forEach(elements, function(element) {
|
||||
modeling.unclaimId(element.businessObject.id, element.businessObject);
|
||||
});
|
||||
if (isLabel(shape)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (is(shape, 'bpmn:Participant') && isExpanded(shape)) {
|
||||
moddle.ids.unclaim(shapeBo.processRef.id);
|
||||
}
|
||||
|
||||
modeling.unclaimId(shapeBo.id, shapeBo);
|
||||
});
|
||||
|
||||
|
||||
this.preExecute('connection.delete', function(event) {
|
||||
var context = event.context,
|
||||
connection = context.connection,
|
||||
connectionBo = connection.businessObject;
|
||||
|
||||
modeling.unclaimId(connectionBo.id, connectionBo);
|
||||
});
|
||||
|
||||
this.preExecute('canvas.updateRoot', function() {
|
||||
var rootElement = canvas.getRootElement(),
|
||||
rootElementBo = rootElement.businessObject;
|
||||
|
||||
moddle.ids.unclaim(rootElementBo.id);
|
||||
});
|
||||
}
|
||||
|
||||
inherits(UnclaimIdBehavior, CommandInterceptor);
|
||||
|
||||
UnclaimIdBehavior.$inject = [ 'eventBus', 'modeling' ];
|
||||
UnclaimIdBehavior.$inject = [ 'canvas', 'injector', 'moddle', 'modeling' ];
|
@ -484,9 +484,15 @@ ReplaceMenuProvider.prototype._getAdHocEntry = function(element) {
|
||||
active: isAdHoc,
|
||||
action: function(event, entry) {
|
||||
if (isAdHoc) {
|
||||
return replaceElement(element, { type: 'bpmn:SubProcess' });
|
||||
return replaceElement(element, { type: 'bpmn:SubProcess' }, {
|
||||
autoResize: false,
|
||||
layoutConnection: false
|
||||
});
|
||||
} else {
|
||||
return replaceElement(element, { type: 'bpmn:AdHocSubProcess' });
|
||||
return replaceElement(element, { type: 'bpmn:AdHocSubProcess' }, {
|
||||
autoResize: false,
|
||||
layoutConnection: false
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -0,0 +1,32 @@
|
||||
<?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:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1fc1ugd" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.3.5">
|
||||
<bpmn:collaboration id="Collaboration_1">
|
||||
<bpmn:participant id="Participant_1" processRef="Process_1" />
|
||||
</bpmn:collaboration>
|
||||
<bpmn:process id="Process_1" isExecutable="true">
|
||||
<bpmn:startEvent id="StartEvent_1">
|
||||
<bpmn:outgoing>SequenceFlow_1</bpmn:outgoing>
|
||||
</bpmn:startEvent>
|
||||
<bpmn:endEvent id="EndEvent_1">
|
||||
<bpmn:incoming>SequenceFlow_1</bpmn:incoming>
|
||||
</bpmn:endEvent>
|
||||
<bpmn:sequenceFlow id="SequenceFlow_1" sourceRef="StartEvent_1" targetRef="EndEvent_1" />
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_1">
|
||||
<bpmndi:BPMNShape id="Participant_0bwhkbn_di" bpmnElement="Participant_1" isHorizontal="true">
|
||||
<dc:Bounds x="-200" y="-25" width="600" height="250" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="StartEvent_1l3vzgi_di" bpmnElement="StartEvent_1">
|
||||
<dc:Bounds x="-98" y="82" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="EndEvent_1nvhsm6_di" bpmnElement="EndEvent_1">
|
||||
<dc:Bounds x="-8" y="82" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="SequenceFlow_12bzkef_di" bpmnElement="SequenceFlow_1">
|
||||
<di:waypoint x="-62" y="100" />
|
||||
<di:waypoint x="-8" y="100" />
|
||||
</bpmndi:BPMNEdge>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
@ -0,0 +1,85 @@
|
||||
import {
|
||||
bootstrapModeler,
|
||||
inject
|
||||
} from 'test/TestHelper';
|
||||
|
||||
import coreModule from 'lib/core';
|
||||
import modelingModule from 'lib/features/modeling';
|
||||
|
||||
|
||||
describe('features/modeling - unclaim id', function() {
|
||||
|
||||
var testModules = [ coreModule, modelingModule ];
|
||||
|
||||
var diagramXML = require('./UnclaimIdBehaviorSpec.bpmn');
|
||||
|
||||
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
||||
|
||||
|
||||
it('should unclaim ID of shape', inject(function(elementRegistry, moddle, modeling) {
|
||||
|
||||
// given
|
||||
var startEvent = elementRegistry.get('StartEvent_1');
|
||||
|
||||
// when
|
||||
modeling.removeElements([ startEvent ]);
|
||||
|
||||
// then
|
||||
expect(moddle.ids.assigned('StartEvent_1')).to.be.false;
|
||||
}));
|
||||
|
||||
|
||||
it('should unclaim ID of process', inject(function(elementRegistry, moddle, modeling) {
|
||||
|
||||
// given
|
||||
var participant = elementRegistry.get('Participant_1');
|
||||
|
||||
// when
|
||||
modeling.removeElements([ participant ]);
|
||||
|
||||
// then
|
||||
expect(moddle.ids.assigned('Process_1')).to.be.false;
|
||||
}));
|
||||
|
||||
|
||||
it('should unclaim ID of connection', inject(function(elementRegistry, moddle, modeling) {
|
||||
|
||||
// given
|
||||
var sequenceFlow = elementRegistry.get('SequenceFlow_1');
|
||||
|
||||
// when
|
||||
modeling.removeElements([ sequenceFlow ]);
|
||||
|
||||
// then
|
||||
expect(moddle.ids.assigned('SequenceFlow_1')).to.be.false;
|
||||
}));
|
||||
|
||||
|
||||
it('should unclaim ID of children', inject(function(elementRegistry, moddle, modeling) {
|
||||
|
||||
// given
|
||||
var participant = elementRegistry.get('Participant_1');
|
||||
|
||||
// when
|
||||
modeling.removeElements([ participant ]);
|
||||
|
||||
// then
|
||||
expect(moddle.ids.assigned('StartEvent_1')).to.be.false;
|
||||
expect(moddle.ids.assigned('SequenceFlow_1')).to.be.false;
|
||||
expect(moddle.ids.assigned('EndEvent_1')).to.be.false;
|
||||
}));
|
||||
|
||||
|
||||
it('should unclaim ID of root', inject(function(elementRegistry, moddle, modeling) {
|
||||
|
||||
// given
|
||||
var participant = elementRegistry.get('Participant_1');
|
||||
|
||||
// when
|
||||
modeling.removeElements([ participant ]);
|
||||
|
||||
// then
|
||||
expect(moddle.ids.assigned('Collaboration_1')).to.be.false;
|
||||
}));
|
||||
|
||||
});
|
@ -1,13 +1,95 @@
|
||||
<?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:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="0.7.0-dev">
|
||||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.3.5">
|
||||
<bpmn:process id="Process_1" isExecutable="false">
|
||||
<bpmn:subProcess id="Task_1" />
|
||||
<bpmn:subProcess id="SubProcess_1">
|
||||
<bpmn:outgoing>SequenceFlow_3</bpmn:outgoing>
|
||||
<bpmn:startEvent id="StartEvent_1">
|
||||
<bpmn:outgoing>SequenceFlow_1</bpmn:outgoing>
|
||||
</bpmn:startEvent>
|
||||
<bpmn:task id="Task_2">
|
||||
<bpmn:incoming>SequenceFlow_1</bpmn:incoming>
|
||||
<bpmn:outgoing>SequenceFlow_2</bpmn:outgoing>
|
||||
</bpmn:task>
|
||||
<bpmn:sequenceFlow id="SequenceFlow_1" sourceRef="StartEvent_1" targetRef="Task_2" />
|
||||
<bpmn:endEvent id="EndEvent_1">
|
||||
<bpmn:incoming>SequenceFlow_2</bpmn:incoming>
|
||||
</bpmn:endEvent>
|
||||
<bpmn:sequenceFlow id="SequenceFlow_2" sourceRef="Task_2" targetRef="EndEvent_1" />
|
||||
</bpmn:subProcess>
|
||||
<bpmn:endEvent id="EndEvent_2">
|
||||
<bpmn:incoming>SequenceFlow_3</bpmn:incoming>
|
||||
</bpmn:endEvent>
|
||||
<bpmn:sequenceFlow id="SequenceFlow_3" sourceRef="SubProcess_1" targetRef="EndEvent_2" />
|
||||
<bpmn:adHocSubProcess id="AdhocSubProcess_1">
|
||||
<bpmn:startEvent id="StartEvent_2">
|
||||
<bpmn:outgoing>SequenceFlow_4</bpmn:outgoing>
|
||||
</bpmn:startEvent>
|
||||
<bpmn:task id="Task_3">
|
||||
<bpmn:incoming>SequenceFlow_4</bpmn:incoming>
|
||||
<bpmn:outgoing>SequenceFlow_5</bpmn:outgoing>
|
||||
</bpmn:task>
|
||||
<bpmn:endEvent id="EndEvent_3">
|
||||
<bpmn:incoming>SequenceFlow_5</bpmn:incoming>
|
||||
</bpmn:endEvent>
|
||||
<bpmn:sequenceFlow id="SequenceFlow_4" sourceRef="StartEvent_2" targetRef="Task_3" />
|
||||
<bpmn:sequenceFlow id="SequenceFlow_5" sourceRef="Task_3" targetRef="EndEvent_3" />
|
||||
</bpmn:adHocSubProcess>
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
|
||||
<bpmndi:BPMNShape id="SubProcess_0loe8m1_di" bpmnElement="Task_1">
|
||||
<dc:Bounds x="149" y="128" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="SubProcess_078mjn9_di" bpmnElement="SubProcess_1" isExpanded="false">
|
||||
<dc:Bounds x="485" y="128" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="StartEvent_06rrfr5_di" bpmnElement="StartEvent_1">
|
||||
<dc:Bounds x="400" y="150" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Task_06m6q8n_di" bpmnElement="Task_2">
|
||||
<dc:Bounds x="490" y="128" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="SequenceFlow_09ygyhb_di" bpmnElement="SequenceFlow_1">
|
||||
<di:waypoint x="436" y="168" />
|
||||
<di:waypoint x="490" y="168" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="EndEvent_1sgr4mk_di" bpmnElement="EndEvent_1">
|
||||
<dc:Bounds x="652" y="150" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="SequenceFlow_10kqeu3_di" bpmnElement="SequenceFlow_2">
|
||||
<di:waypoint x="590" y="168" />
|
||||
<di:waypoint x="652" y="168" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="EndEvent_1tbfi2d_di" bpmnElement="EndEvent_2">
|
||||
<dc:Bounds x="762" y="232" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="SequenceFlow_18gyvps_di" bpmnElement="SequenceFlow_3">
|
||||
<di:waypoint x="585" y="168" />
|
||||
<di:waypoint x="670" y="168" />
|
||||
<di:waypoint x="670" y="250" />
|
||||
<di:waypoint x="762" y="250" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="StartEvent_1kebej2_di" bpmnElement="StartEvent_2">
|
||||
<dc:Bounds x="855" y="150" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Task_1qnpo60_di" bpmnElement="Task_3">
|
||||
<dc:Bounds x="945" y="128" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="SequenceFlow_1ffetd8_di" bpmnElement="SequenceFlow_4">
|
||||
<di:waypoint x="891" y="168" />
|
||||
<di:waypoint x="945" y="168" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="EndEvent_0a4p737_di" bpmnElement="EndEvent_3">
|
||||
<dc:Bounds x="1107" y="150" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="SequenceFlow_1qs2ip4_di" bpmnElement="SequenceFlow_5">
|
||||
<di:waypoint x="1045" y="168" />
|
||||
<di:waypoint x="1107" y="168" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="AdHocSubProcess_0lfb35q_di" bpmnElement="AdhocSubProcess_1" isExpanded="false">
|
||||
<dc:Bounds x="940" y="128" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* global sinon */
|
||||
|
||||
import {
|
||||
bootstrapModeler,
|
||||
getBpmnJS,
|
||||
@ -8,10 +10,11 @@ import {
|
||||
createEvent as globalEvent
|
||||
} from '../../../util/MockEvents';
|
||||
|
||||
import autoResizeModule from 'lib/features/auto-resize';
|
||||
import coreModule from 'lib/core';
|
||||
import customRulesModule from '../../../util/custom-rules';
|
||||
import modelingModule from 'lib/features/modeling';
|
||||
import replaceMenuProviderModule from 'lib/features/popup-menu';
|
||||
import customRulesModule from '../../../util/custom-rules';
|
||||
|
||||
import {
|
||||
query as domQuery,
|
||||
@ -23,6 +26,8 @@ import { is } from 'lib/util/ModelUtil';
|
||||
|
||||
import { isExpanded } from 'lib/util/DiUtil';
|
||||
|
||||
var spy = sinon.spy;
|
||||
|
||||
|
||||
describe('features/popup-menu - replace menu provider', function() {
|
||||
|
||||
@ -1778,6 +1783,100 @@ describe('features/popup-menu - replace menu provider', function() {
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe('adhoc sub process', function() {
|
||||
|
||||
var diagramXML = require('./ReplaceMenuProvider.collapsedSubProcess.bpmn');
|
||||
|
||||
beforeEach(bootstrapModeler(diagramXML, {
|
||||
modules: testModules.concat(autoResizeModule)
|
||||
}));
|
||||
|
||||
|
||||
describe('sub process -> adhoc', function() {
|
||||
|
||||
it('should not resize', inject(function(elementRegistry, modeling, popupMenu) {
|
||||
|
||||
// given
|
||||
var subProcess = elementRegistry.get('SubProcess_1');
|
||||
|
||||
var resizeShapeSpy = spy(modeling, 'resizeShape');
|
||||
|
||||
// when
|
||||
openPopup(subProcess);
|
||||
|
||||
var adHocEntry = queryEntry('toggle-adhoc');
|
||||
|
||||
popupMenu.trigger(globalEvent(adHocEntry, { x: 0, y: 0 }));
|
||||
|
||||
// then
|
||||
expect(resizeShapeSpy).not.to.have.been.called;
|
||||
}));
|
||||
|
||||
|
||||
it('should not lay out connection', inject(function(elementRegistry, modeling, popupMenu) {
|
||||
|
||||
// given
|
||||
var subProcess = elementRegistry.get('SubProcess_1');
|
||||
|
||||
var layoutConnectionSpy = spy(modeling, 'layoutConnection');
|
||||
|
||||
// when
|
||||
openPopup(subProcess);
|
||||
|
||||
var adHocEntry = queryEntry('toggle-adhoc');
|
||||
|
||||
popupMenu.trigger(globalEvent(adHocEntry, { x: 0, y: 0 }));
|
||||
|
||||
// then
|
||||
expect(layoutConnectionSpy).not.to.have.been.called;
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
describe('adhoc -> sub process', function() {
|
||||
|
||||
it('should not resize', inject(function(elementRegistry, modeling, popupMenu) {
|
||||
|
||||
// given
|
||||
var adhocSubProcess = elementRegistry.get('AdhocSubProcess_1');
|
||||
|
||||
var resizeShapeSpy = spy(modeling, 'resizeShape');
|
||||
|
||||
// when
|
||||
openPopup(adhocSubProcess);
|
||||
|
||||
var adHocEntry = queryEntry('toggle-adhoc');
|
||||
|
||||
popupMenu.trigger(globalEvent(adHocEntry, { x: 0, y: 0 }));
|
||||
|
||||
// then
|
||||
expect(resizeShapeSpy).not.to.have.been.called;
|
||||
}));
|
||||
|
||||
|
||||
it('should not lay out connection', inject(function(elementRegistry, modeling, popupMenu) {
|
||||
|
||||
// given
|
||||
var adhocSubProcess = elementRegistry.get('AdhocSubProcess_1');
|
||||
|
||||
var layoutConnectionSpy = spy(modeling, 'layoutConnection');
|
||||
|
||||
// when
|
||||
openPopup(adhocSubProcess);
|
||||
|
||||
var adHocEntry = queryEntry('toggle-adhoc');
|
||||
|
||||
popupMenu.trigger(globalEvent(adHocEntry, { x: 0, y: 0 }));
|
||||
|
||||
// then
|
||||
expect(layoutConnectionSpy).not.to.have.been.called;
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user