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,21 +1327,26 @@ 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;
// conditional flow marker var source;
if (sequenceFlow.conditionExpression && source.$instanceOf('bpmn:Activity')) {
svgAttr(path, {
markerStart: marker('conditional-flow-marker', fill, stroke)
});
}
// default marker if (element.source) {
if (source.default && (source.$instanceOf('bpmn:Gateway') || source.$instanceOf('bpmn:Activity')) && source = element.source.businessObject;
source.default === sequenceFlow) {
svgAttr(path, { // conditional flow marker
markerStart: marker('conditional-default-flow-marker', fill, stroke) if (sequenceFlow.conditionExpression && source.$instanceOf('bpmn:Activity')) {
}); svgAttr(path, {
markerStart: marker('conditional-flow-marker', fill, stroke)
});
}
// default marker
if (source.default && (source.$instanceOf('bpmn:Gateway') || source.$instanceOf('bpmn:Activity')) &&
source.default === sequenceFlow) {
svgAttr(path, {
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');