mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-01-12 10:04:16 +00:00
chore(group-behavior): move category creation to util
This commit is contained in:
parent
bc4b6cbfd8
commit
57f516ef32
@ -12,6 +12,9 @@ import {
|
|||||||
is
|
is
|
||||||
} from '../../../util/ModelUtil';
|
} from '../../../util/ModelUtil';
|
||||||
|
|
||||||
|
import {
|
||||||
|
createCategoryValue
|
||||||
|
} from './util/CategoryUtil';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BPMN specific Group behavior
|
* BPMN specific Group behavior
|
||||||
@ -146,17 +149,8 @@ export default function GroupBehavior(eventBus, bpmnFactory, canvas, elementRegi
|
|||||||
|
|
||||||
if (is(businessObject, 'bpmn:Group') && !businessObject.categoryValueRef) {
|
if (is(businessObject, 'bpmn:Group') && !businessObject.categoryValueRef) {
|
||||||
|
|
||||||
var definitions = getDefinitions();
|
var definitions = getDefinitions(),
|
||||||
|
categoryValue = createCategoryValue(definitions, bpmnFactory);
|
||||||
var categoryValue = bpmnFactory.create('bpmn:CategoryValue'),
|
|
||||||
category = bpmnFactory.create('bpmn:Category', {
|
|
||||||
categoryValue: [ categoryValue ]
|
|
||||||
});
|
|
||||||
|
|
||||||
// add to correct place
|
|
||||||
collectionAdd(definitions.get('rootElements'), category);
|
|
||||||
getBusinessObject(category).$parent = definitions;
|
|
||||||
getBusinessObject(categoryValue).$parent = category;
|
|
||||||
|
|
||||||
// link the reference to the Group
|
// link the reference to the Group
|
||||||
businessObject.categoryValueRef = categoryValue;
|
businessObject.categoryValueRef = categoryValue;
|
||||||
|
30
lib/features/modeling/behavior/util/CategoryUtil.js
Normal file
30
lib/features/modeling/behavior/util/CategoryUtil.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import {
|
||||||
|
add as collectionAdd
|
||||||
|
} from 'diagram-js/lib/util/Collections';
|
||||||
|
|
||||||
|
import {
|
||||||
|
getBusinessObject
|
||||||
|
} from '../../../../util/ModelUtil';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new bpmn:CategoryValue inside a new bpmn:Category
|
||||||
|
*
|
||||||
|
* @param {ModdleElement} definitions
|
||||||
|
* @param {BpmnFactory} bpmnFactory
|
||||||
|
*
|
||||||
|
* @return {ModdleElement} categoryValue.
|
||||||
|
*/
|
||||||
|
export function createCategoryValue(definitions, bpmnFactory) {
|
||||||
|
var categoryValue = bpmnFactory.create('bpmn:CategoryValue'),
|
||||||
|
category = bpmnFactory.create('bpmn:Category', {
|
||||||
|
categoryValue: [ categoryValue ]
|
||||||
|
});
|
||||||
|
|
||||||
|
// add to correct place
|
||||||
|
collectionAdd(definitions.get('rootElements'), category);
|
||||||
|
getBusinessObject(category).$parent = definitions;
|
||||||
|
getBusinessObject(categoryValue).$parent = category;
|
||||||
|
|
||||||
|
return categoryValue;
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user