fix(rule): allow drop of associations

close #202
This commit is contained in:
jdotzki 2015-03-25 13:45:04 +01:00
parent 7191af8978
commit 8cd3c78d5e
3 changed files with 60 additions and 4 deletions

View File

@ -208,6 +208,12 @@ ModelingRules.prototype.init = function() {
return true; return true;
} }
if (businessObject.$instanceOf('bpmn:Association') &&
targetBusinessObject.$instanceOf('bpmn:FlowElementsContainer')) {
return true;
}
return false; return false;
} }

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
id="Definitions_1"
targetNamespace="http://bpmn.io/schema/bpmn">
<bpmn:process id="Process_1" isExecutable="false">
<bpmn:startEvent id="StartEvent_1" />
<bpmn:textAnnotation id="TextAnnotation_1">
<bpmn:text>A label</bpmn:text>
</bpmn:textAnnotation>
<bpmn:association id="Association_1" sourceRef="StartEvent_1" targetRef="TextAnnotation_1" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="173" y="102" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="TextAnnotation_1_di" bpmnElement="TextAnnotation_1">
<dc:Bounds x="285" y="24" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Association_1_di" bpmnElement="Association_1">
<di:waypoint xsi:type="dc:Point" x="207" y="114" />
<di:waypoint xsi:type="dc:Point" x="285" y="83" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

View File

@ -1,12 +1,9 @@
'use strict'; 'use strict';
var Matchers = require('../../../Matchers'), var Matchers = require('../../../Matchers');
TestHelper = require('../../../TestHelper');
/* global bootstrapModeler, inject */ /* global bootstrapModeler, inject */
var _ = require('lodash');
var fs = require('fs'); var fs = require('fs');
var modelingModule = require('../../../../lib/features/modeling'), var modelingModule = require('../../../../lib/features/modeling'),
@ -23,6 +20,7 @@ describe('features/ModelingRules', function() {
var eventGatewaysEdgeXML = var eventGatewaysEdgeXML =
fs.readFileSync('test/fixtures/bpmn/features/rules/event-based-gateway-outgoing-edge.bpmn', 'utf8'); fs.readFileSync('test/fixtures/bpmn/features/rules/event-based-gateway-outgoing-edge.bpmn', 'utf8');
var linkEventXML = fs.readFileSync('test/fixtures/bpmn/features/rules/link-event.bpmn', 'utf8'); var linkEventXML = fs.readFileSync('test/fixtures/bpmn/features/rules/link-event.bpmn', 'utf8');
var textAnnotationXML = fs.readFileSync('test/fixtures/bpmn/features/rules/text-annotation-association.bpmn', 'utf8');
var testModules = [ coreModule, modelingModule, rulesModule ]; var testModules = [ coreModule, modelingModule, rulesModule ];
@ -278,4 +276,26 @@ describe('features/ModelingRules', function() {
expect(allowed).toBe(true); expect(allowed).toBe(true);
})); }));
}); });
describe('Association', function() {
beforeEach(bootstrapModeler(textAnnotationXML, { modules: testModules }));
it('should allow drop on process', inject(function(elementRegistry, rules) {
// given
var association = elementRegistry.get('Association_1'),
parent = elementRegistry.get('Process_1');
// when
var allowed = rules.allowed('shapes.move', {
connection: null,
shapes: [ association ],
newParent: parent
});
// then
expect(allowed).toBe(true);
}));
});
}); });