parent
cdc0894012
commit
1e202d475f
|
@ -24,7 +24,7 @@ var HIGH_PRIORITY = 2000;
|
||||||
*/
|
*/
|
||||||
export default function GroupBehavior(
|
export default function GroupBehavior(
|
||||||
bpmnFactory,
|
bpmnFactory,
|
||||||
canvas,
|
bpmnjs,
|
||||||
elementRegistry,
|
elementRegistry,
|
||||||
eventBus,
|
eventBus,
|
||||||
injector,
|
injector,
|
||||||
|
@ -32,18 +32,6 @@ export default function GroupBehavior(
|
||||||
) {
|
) {
|
||||||
injector.invoke(CommandInterceptor, this);
|
injector.invoke(CommandInterceptor, this);
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets process definitions
|
|
||||||
*
|
|
||||||
* @return {ModdleElement} definitions
|
|
||||||
*/
|
|
||||||
function getDefinitions() {
|
|
||||||
var rootElement = canvas.getRootElement(),
|
|
||||||
businessObject = getBusinessObject(rootElement);
|
|
||||||
|
|
||||||
return businessObject.$parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a referenced category value for a given group shape
|
* Removes a referenced category value for a given group shape
|
||||||
*
|
*
|
||||||
|
@ -79,7 +67,7 @@ export default function GroupBehavior(
|
||||||
*/
|
*/
|
||||||
function removeCategory(category) {
|
function removeCategory(category) {
|
||||||
|
|
||||||
var definitions = getDefinitions();
|
var definitions = bpmnjs.getDefinitions();
|
||||||
|
|
||||||
collectionRemove(definitions.get('rootElements'), category);
|
collectionRemove(definitions.get('rootElements'), category);
|
||||||
}
|
}
|
||||||
|
@ -144,7 +132,7 @@ export default function GroupBehavior(
|
||||||
|
|
||||||
var businessObject = getBusinessObject(shape),
|
var businessObject = getBusinessObject(shape),
|
||||||
categoryValueRef = businessObject.categoryValueRef,
|
categoryValueRef = businessObject.categoryValueRef,
|
||||||
definitions = getDefinitions(),
|
definitions = bpmnjs.getDefinitions(),
|
||||||
category = categoryValueRef ? categoryValueRef.$parent : null;
|
category = categoryValueRef ? categoryValueRef.$parent : null;
|
||||||
|
|
||||||
collectionAdd(category.get('categoryValue'), categoryValueRef);
|
collectionAdd(category.get('categoryValue'), categoryValueRef);
|
||||||
|
@ -162,7 +150,7 @@ export default function GroupBehavior(
|
||||||
|
|
||||||
if (is(businessObject, 'bpmn:Group') && !businessObject.categoryValueRef) {
|
if (is(businessObject, 'bpmn:Group') && !businessObject.categoryValueRef) {
|
||||||
|
|
||||||
var definitions = getDefinitions(),
|
var definitions = bpmnjs.getDefinitions(),
|
||||||
categoryValue = createCategoryValue(definitions, bpmnFactory);
|
categoryValue = createCategoryValue(definitions, bpmnFactory);
|
||||||
|
|
||||||
// link the reference to the Group
|
// link the reference to the Group
|
||||||
|
@ -190,7 +178,7 @@ export default function GroupBehavior(
|
||||||
categoryValue;
|
categoryValue;
|
||||||
|
|
||||||
if (is(property, 'bpmn:CategoryValue')) {
|
if (is(property, 'bpmn:CategoryValue')) {
|
||||||
categoryValue = createCategoryValue(getDefinitions(), bpmnFactory);
|
categoryValue = createCategoryValue(bpmnjs.getDefinitions(), bpmnFactory);
|
||||||
|
|
||||||
// return copy of category
|
// return copy of category
|
||||||
return moddleCopy.copyElement(property, categoryValue);
|
return moddleCopy.copyElement(property, categoryValue);
|
||||||
|
@ -201,7 +189,7 @@ export default function GroupBehavior(
|
||||||
|
|
||||||
GroupBehavior.$inject = [
|
GroupBehavior.$inject = [
|
||||||
'bpmnFactory',
|
'bpmnFactory',
|
||||||
'canvas',
|
'bpmnjs',
|
||||||
'elementRegistry',
|
'elementRegistry',
|
||||||
'eventBus',
|
'eventBus',
|
||||||
'injector',
|
'injector',
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
<categoryValue id="CategoryValue_3" value="Value 3" />
|
<categoryValue id="CategoryValue_3" value="Value 3" />
|
||||||
</category>
|
</category>
|
||||||
<process id="Process_1" isExecutable="false">
|
<process id="Process_1" isExecutable="false">
|
||||||
|
<subProcess id="Subprocess_1" />
|
||||||
<group id="Group_1" categoryValueRef="CategoryValue_1" />
|
<group id="Group_1" categoryValueRef="CategoryValue_1" />
|
||||||
<group id="Group_2" categoryValueRef="CategoryValue_1" />
|
<group id="Group_2" categoryValueRef="CategoryValue_1" />
|
||||||
<group id="Group_3" categoryValueRef="CategoryValue_2" />
|
<group id="Group_3" categoryValueRef="CategoryValue_2" />
|
||||||
|
@ -15,6 +16,9 @@
|
||||||
</process>
|
</process>
|
||||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||||
<bpmndi:BPMNPlane bpmnElement="Process_1">
|
<bpmndi:BPMNPlane bpmnElement="Process_1">
|
||||||
|
<bpmndi:BPMNShape id="Activity_0zvwgk9_di" bpmnElement="Subprocess_1">
|
||||||
|
<omgdc:Bounds x="160" y="360" width="100" height="80" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
<bpmndi:BPMNShape id="Group_1_di" bpmnElement="Group_1">
|
<bpmndi:BPMNShape id="Group_1_di" bpmnElement="Group_1">
|
||||||
<omgdc:Bounds x="162" y="75" width="200" height="200" />
|
<omgdc:Bounds x="162" y="75" width="200" height="200" />
|
||||||
<bpmndi:BPMNLabel>
|
<bpmndi:BPMNLabel>
|
||||||
|
@ -32,4 +36,7 @@
|
||||||
</bpmndi:BPMNShape>
|
</bpmndi:BPMNShape>
|
||||||
</bpmndi:BPMNPlane>
|
</bpmndi:BPMNPlane>
|
||||||
</bpmndi:BPMNDiagram>
|
</bpmndi:BPMNDiagram>
|
||||||
|
<bpmndi:BPMNDiagram id="BPMNDiagram_1g3s90h">
|
||||||
|
<bpmndi:BPMNPlane id="BPMNPlane_1ezo7xu" bpmnElement="Subprocess_1" />
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
</definitions>
|
</definitions>
|
|
@ -220,6 +220,47 @@ describe('features/modeling/behavior - groups', function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it('should always create new Category in definitions',
|
||||||
|
inject(function(canvas, elementFactory, modeling, bpmnjs) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var group = elementFactory.createShape({ type: 'bpmn:Group' }),
|
||||||
|
root = canvas.findRoot('Subprocess_1_plane'),
|
||||||
|
rootParent = getBusinessObject(root).$parent,
|
||||||
|
definitions = bpmnjs._definitions;
|
||||||
|
|
||||||
|
canvas.setRootElement(root);
|
||||||
|
|
||||||
|
// when
|
||||||
|
var groupShape = modeling.createShape(group, { x: 100, y: 100 }, root),
|
||||||
|
categoryValueRef = getBusinessObject(groupShape).categoryValueRef,
|
||||||
|
category = categoryValueRef.$parent;
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(categoryValueRef).to.exist;
|
||||||
|
expect(category).to.exist;
|
||||||
|
|
||||||
|
expectIncludedOrNot(
|
||||||
|
category.get('categoryValue'),
|
||||||
|
categoryValueRef,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
expectIncludedOrNot(
|
||||||
|
definitions.get('rootElements'),
|
||||||
|
category,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
expectIncludedOrNot(
|
||||||
|
rootParent.get('rootElements'),
|
||||||
|
category,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue