Skip to content

Commit

Permalink
fix(import): set <isFrame> property on import
Browse files Browse the repository at this point in the history
Closes #1278
  • Loading branch information
Niklas Kiefer authored and nikku committed Feb 7, 2020
1 parent b9bf021 commit 566f0ea
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/import/BpmnImporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ BpmnImporter.prototype.add = function(semantic, parentElement) {
// SHAPE
else if (is(di, 'bpmndi:BPMNShape')) {

var collapsed = !isExpanded(semantic);
var collapsed = !isExpanded(semantic),
isFrame = isFrameElement(semantic);
hidden = parentElement && (parentElement.hidden || parentElement.collapsed);

var bounds = semantic.di.bounds;
Expand All @@ -126,7 +127,8 @@ BpmnImporter.prototype.add = function(semantic, parentElement) {
x: Math.round(bounds.x),
y: Math.round(bounds.y),
width: Math.round(bounds.width),
height: Math.round(bounds.height)
height: Math.round(bounds.height),
isFrame: isFrame
}));

if (is(semantic, 'bpmn:BoundaryEvent')) {
Expand Down Expand Up @@ -332,4 +334,8 @@ function isPointInsideBBox(bbox, point) {
x <= bbox.x + bbox.width &&
y >= bbox.y &&
y <= bbox.y + bbox.height;
}

function isFrameElement(semantic) {
return is(semantic, 'bpmn:Group');
}
16 changes: 16 additions & 0 deletions test/fixtures/bpmn/import/groups.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="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" id="simple" targetNamespace="http://bpmn.io/schema/bpmn" exporter="camunda modeler" exporterVersion="2.6.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:process id="Process_1" isExecutable="false">
<bpmn2:group id="Group_1" categoryValueRef="CategoryValue_1o9po2j" />
</bpmn2:process>
<bpmn2:category id="Category_0fj5y1s">
<bpmn2:categoryValue id="CategoryValue_1o9po2j" />
</bpmn2:category>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNShape id="Group_1_di" bpmnElement="Group_1">
<dc:Bounds x="280" y="60" width="430" height="360" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
32 changes: 32 additions & 0 deletions test/spec/import/ImporterSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,38 @@ describe('import - Importer', function() {
});
});


it('should import groups', function(done) {

// given
var xml = require('../../fixtures/bpmn/import/groups.bpmn');

var events = [];

// log events
diagram.get('eventBus').on('bpmnElement.added', function(e) {
events.push({
type: 'add',
semantic: e.element.businessObject.id,
di: e.element.businessObject.di.id,
diagramElement: e.element && e.element.id,
isFrame: e.element && e.element.isFrame
});
});

// when
runImport(diagram, xml, function(err) {

// then
expect(events).to.eql([
{ type: 'add', semantic: 'Process_1', di: 'BPMNPlane_1', diagramElement: 'Process_1', isFrame: undefined },
{ type: 'add', semantic: 'Group_1', di: 'Group_1_di', diagramElement: 'Group_1', isFrame: true }
]);

done(err);
});
});

});


Expand Down

0 comments on commit 566f0ea

Please sign in to comment.