chore(draw): render connections without source

This allows us to renders temporary connections,
i.e. during create / connect.
This commit is contained in:
Nico Rehwaldt 2017-12-17 00:06:01 +01:00
parent 0dd5c9cb6c
commit 6b5277b936
2 changed files with 57 additions and 14 deletions

View File

@ -1327,7 +1327,11 @@ function BpmnRenderer(eventBus, styles, pathMap, canvas, priority) {
var path = drawPath(parentGfx, pathData, attrs); var path = drawPath(parentGfx, pathData, attrs);
var sequenceFlow = getSemantic(element); var sequenceFlow = getSemantic(element);
var source = element.source.businessObject;
var source;
if (element.source) {
source = element.source.businessObject;
// conditional flow marker // conditional flow marker
if (sequenceFlow.conditionExpression && source.$instanceOf('bpmn:Activity')) { if (sequenceFlow.conditionExpression && source.$instanceOf('bpmn:Activity')) {
@ -1343,6 +1347,7 @@ function BpmnRenderer(eventBus, styles, pathMap, canvas, priority) {
markerStart: marker('conditional-default-flow-marker', fill, stroke) markerStart: marker('conditional-default-flow-marker', fill, stroke)
}); });
} }
}
return path; return path;
}, },

View File

@ -2,8 +2,11 @@
require('../../TestHelper'); require('../../TestHelper');
var svgCreate = require('tiny-svg/lib/create');
var coreModule = require('../../../lib/core'), var coreModule = require('../../../lib/core'),
rendererModule = require('../../../lib/draw'); rendererModule = require('../../../lib/draw'),
modelingModule = require('../../../lib/features/modeling');
var domQuery = require('min-dom/lib/query'); var domQuery = require('min-dom/lib/query');
@ -249,6 +252,41 @@ describe('draw - bpmn renderer', function() {
}); });
it('should render sequenceFlows without source', function(done) {
var xml = require('../../fixtures/bpmn/draw/colors.bpmn');
bootstrapModeler(xml, {
modules: [
coreModule,
rendererModule,
modelingModule
]
})(function(err) {
inject(function(elementFactory, graphicsFactory) {
// given
var g = svgCreate('g');
var connection = elementFactory.create('connection', {
type: 'bpmn:SequenceFlow',
waypoints: [
{ x: 0, y: 0 },
{ x: 10, y: 100 }
]
});
var gfx = graphicsFactory.drawConnection(g, connection);
expect(gfx).to.exist;
})();
done(err);
});
});
describe('path', function() { describe('path', function() {
var diagramXML = require('./BpmnRenderer.simple-cropping.bpmn'); var diagramXML = require('./BpmnRenderer.simple-cropping.bpmn');