Skip to content

Commit

Permalink
feat(ElementFactory): add #isFrame property on group creation
Browse files Browse the repository at this point in the history
This allows basic support for diagram-js frame elements.

Closes #959
Closes #960
  • Loading branch information
Niklas Kiefer committed May 7, 2019
1 parent 13f1e05 commit 89886d7
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/features/modeling/ElementFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
}
}

if (is(businessObject, 'bpmn:Group')) {
attrs = assign({
isFrame: true
}, attrs);
}

if (attrs.colors) {
assign(businessObject.di, attrs.colors);

Expand Down
26 changes: 26 additions & 0 deletions test/spec/import/elements/Groups.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="sid-0fcc2144-457b-4505-9e44-ff673663e3bc" targetNamespace="http://www.signavio.com/bpmn20" exporter="Camunda Modeler" exporterVersion="3.0.1" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL http://www.omg.org/spec/BPMN/2.0/20100501/BPMN20.xsd">
<category id="Category_1">
<categoryValue id="CategoryValue_1" value="my group" />
</category>
<process id="Process_1" processType="None" isExecutable="false">
<group id="Group_1" categoryValueRef="CategoryValue_1" />
<group id="Group_2" categoryValueRef="CategoryValue_1" />
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNShape id="Group_1di" bpmnElement="Group_1">
<omgdc:Bounds x="180" y="105" width="188" height="154" />
<bpmndi:BPMNLabel>
<omgdc:Bounds x="184" y="107" width="58.28571319580078" height="15" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Group_2di" bpmnElement="Group_2">
<omgdc:Bounds x="180" y="279" width="188" height="154" />
<bpmndi:BPMNLabel>
<omgdc:Bounds x="184" y="107" width="58.28571319580078" height="15" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
35 changes: 35 additions & 0 deletions test/spec/import/elements/GroupsSpec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {
bootstrapModeler,
inject
} from 'test/TestHelper';


describe('import - groups', function() {

describe('should import groups', function() {

it('with frame property set', function(done) {
var xml = require('./Groups.bpmn');

// given
bootstrapModeler(xml)(function(err) {

// when
inject(function(elementRegistry) {

// then
var groupElement = elementRegistry.get('Group_1');

expect(groupElement).to.exist;
expect(groupElement.isFrame).to.be.true;

done(err);
})();

});
});


});

});

0 comments on commit 89886d7

Please sign in to comment.