fix(modeling): manhattan layout compensation association
Related to #291
This commit is contained in:
parent
5ab0db65a5
commit
206daa1154
|
@ -38,8 +38,12 @@ BpmnLayouter.prototype.layoutConnection = function(connection, layoutHints) {
|
|||
// TODO (nre): support vertical modeling
|
||||
// and invert preferredLayouts accordingly
|
||||
|
||||
if ((is(connection, 'bpmn:Association') || is(connection, 'bpmn:DataAssociation')) && waypoints) {
|
||||
return waypoints;
|
||||
if (is(connection, 'bpmn:Association') ||
|
||||
is(connection, 'bpmn:DataAssociation')) {
|
||||
|
||||
if (waypoints && !isCompensationAssociation(connection)) {
|
||||
return waypoints;
|
||||
}
|
||||
}
|
||||
|
||||
// manhattan layout sequence / message flows
|
||||
|
@ -63,7 +67,8 @@ BpmnLayouter.prototype.layoutConnection = function(connection, layoutHints) {
|
|||
// (1) outgoing of BoundaryEvents -> layout h:v or v:h based on attach orientation
|
||||
// (2) incoming / outgoing of Gateway -> v:h (outgoing), h:v (incoming)
|
||||
//
|
||||
if (is(connection, 'bpmn:SequenceFlow')) {
|
||||
if (is(connection, 'bpmn:SequenceFlow') ||
|
||||
isCompensationAssociation(connection)) {
|
||||
|
||||
// make sure boundary event connections do
|
||||
// not look ugly =:>
|
||||
|
@ -136,3 +141,13 @@ function getConnectionDocking(waypoints, idx, shape) {
|
|||
|
||||
return point ? (point.original || point) : getMid(shape);
|
||||
}
|
||||
|
||||
function isCompensationAssociation(connection) {
|
||||
|
||||
var source = connection.source,
|
||||
target = connection.target;
|
||||
|
||||
return is(target, 'bpmn:Activity') &&
|
||||
is(source, 'bpmn:BoundaryEvent') &&
|
||||
target.businessObject.isForCompensation;
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn">
|
||||
<bpmn:process id="Process_1" isExecutable="false">
|
||||
<bpmn:task id="Task_09clsti" />
|
||||
<bpmn:boundaryEvent id="CompensationBoundary" attachedToRef="Task_09clsti">
|
||||
<bpmn:compensateEventDefinition />
|
||||
</bpmn:boundaryEvent>
|
||||
<bpmn:task id="CompensationActivity" isForCompensation="true" />
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
|
||||
<bpmndi:BPMNShape id="Task_09clsti_di" bpmnElement="Task_09clsti">
|
||||
<dc:Bounds x="45" y="44" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="CompensationBoundary_di" bpmnElement="CompensationBoundary">
|
||||
<dc:Bounds x="89" y="106" width="36" height="36" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="62" y="142" width="90" height="20" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="CompensationActivity_di" bpmnElement="CompensationActivity">
|
||||
<dc:Bounds x="206" y="214" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
|
@ -0,0 +1,46 @@
|
|||
'use strict';
|
||||
|
||||
require('../../../../TestHelper');
|
||||
|
||||
/* global inject, bootstrapModeler */
|
||||
|
||||
var find = require('lodash/collection/find');
|
||||
|
||||
var modelingModule = require('../../../../../lib/features/modeling');
|
||||
|
||||
|
||||
describe('modeling/behavior - CompensationAssociation', function(){
|
||||
|
||||
var diagramXML = require('./CompensationAssociationBehavior.bpmn');
|
||||
|
||||
beforeEach(bootstrapModeler(diagramXML, { modules: modelingModule }));
|
||||
|
||||
|
||||
it('should manhattan layout', inject(function(modeling, elementRegistry) {
|
||||
|
||||
// given
|
||||
var boundaryShape = elementRegistry.get('CompensationBoundary'),
|
||||
activityShape = elementRegistry.get('CompensationActivity');
|
||||
|
||||
|
||||
// when
|
||||
var newConnection = modeling.connect(boundaryShape, activityShape, {
|
||||
type: 'bpmn:DataInputAssociation'
|
||||
});
|
||||
|
||||
// then
|
||||
expect(waypoints(newConnection)).to.eql([
|
||||
{ x: 107, y: 142 },
|
||||
{ x: 107, y: 254 },
|
||||
{ x: 206, y: 254 }
|
||||
]);
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
|
||||
function waypoints(connection) {
|
||||
return connection.waypoints.map(function(wp) {
|
||||
return { x: wp.x, y: wp.y };
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue