From acd2fe520b3cdb2144f3918511a3c35513ac2a5a Mon Sep 17 00:00:00 2001 From: Niklas Kiefer Date: Wed, 24 Oct 2018 13:43:34 +0200 Subject: [PATCH] feat(draw): render group names Closes #844 --- lib/draw/BpmnRenderer.js | 20 ++++++++++++++++++- test/fixtures/bpmn/draw/group-name.bpmn | 26 +++++++++++++++++++++++++ test/spec/draw/BpmnRendererSpec.js | 17 ++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/bpmn/draw/group-name.bpmn diff --git a/lib/draw/BpmnRenderer.js b/lib/draw/BpmnRenderer.js index c29e5cd7..84253669 100644 --- a/lib/draw/BpmnRenderer.js +++ b/lib/draw/BpmnRenderer.js @@ -1577,12 +1577,30 @@ export default function BpmnRenderer( return outer; }, 'bpmn:Group': function(parentGfx, element) { - return drawRect(parentGfx, element.width, element.height, TASK_BORDER_RADIUS, { + var semantic = getSemantic(element), + di = getDi(element); + + var group = drawRect(parentGfx, element.width, element.height, TASK_BORDER_RADIUS, { strokeWidth: 1, strokeDasharray: '8,3,1,3', fill: 'none', pointerEvents: 'none' }); + + var categoryValueRef = semantic.categoryValueRef || {}; + + if (categoryValueRef.value) { + var box = di.label ? di.label.bounds : element; + + renderLabel(parentGfx, categoryValueRef.value, { + box: box, + style: { + fill: getStrokeColor(element, defaultStrokeColor) + } + }); + } + + return group; }, 'label': function(parentGfx, element) { return renderExternalLabel(parentGfx, element); diff --git a/test/fixtures/bpmn/draw/group-name.bpmn b/test/fixtures/bpmn/draw/group-name.bpmn new file mode 100644 index 00000000..835131fb --- /dev/null +++ b/test/fixtures/bpmn/draw/group-name.bpmn @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/spec/draw/BpmnRendererSpec.js b/test/spec/draw/BpmnRendererSpec.js index d94a271f..8c9acf88 100644 --- a/test/spec/draw/BpmnRendererSpec.js +++ b/test/spec/draw/BpmnRendererSpec.js @@ -123,6 +123,23 @@ describe('draw - bpmn renderer', function() { }); + it('should render group name', function(done) { + var xml = require('../../fixtures/bpmn/draw/group-name.bpmn'); + + bootstrapViewer(xml).call(this, function(err) { + + inject(function(elementRegistry) { + + var groupGfx = elementRegistry.getGraphics('Group_1'); + + expect(domQuery('.djs-label', groupGfx)).to.exist; + + done(err); + })(); + }); + }); + + it('should render message marker', function(done) { var xml = require('../../fixtures/bpmn/draw/message-marker.bpmn'); bootstrapViewer(xml).call(this, checkErrors(done));