From 89886d7c121fdfefb7d4713b0519829d61cc8fa0 Mon Sep 17 00:00:00 2001 From: Niklas Kiefer Date: Thu, 2 May 2019 10:38:33 +0200 Subject: [PATCH] feat(ElementFactory): add #isFrame property on group creation This allows basic support for diagram-js frame elements. Closes #959 Closes #960 --- lib/features/modeling/ElementFactory.js | 6 +++++ test/spec/import/elements/Groups.bpmn | 26 ++++++++++++++++++ test/spec/import/elements/GroupsSpec.js | 35 +++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 test/spec/import/elements/Groups.bpmn create mode 100644 test/spec/import/elements/GroupsSpec.js diff --git a/lib/features/modeling/ElementFactory.js b/lib/features/modeling/ElementFactory.js index b8c57b14..bbb7f385 100644 --- a/lib/features/modeling/ElementFactory.js +++ b/lib/features/modeling/ElementFactory.js @@ -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); diff --git a/test/spec/import/elements/Groups.bpmn b/test/spec/import/elements/Groups.bpmn new file mode 100644 index 00000000..03f800aa --- /dev/null +++ b/test/spec/import/elements/Groups.bpmn @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/spec/import/elements/GroupsSpec.js b/test/spec/import/elements/GroupsSpec.js new file mode 100644 index 00000000..0a61de07 --- /dev/null +++ b/test/spec/import/elements/GroupsSpec.js @@ -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); + })(); + + }); + }); + + + }); + +}); \ No newline at end of file