all files / bpmn-js/lib/features/modeling/behavior/util/ CategoryUtil.js

100% Statements 6/6
100% Branches 0/0
100% Functions 1/1
100% Lines 6/6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30                                  11× 11×         11× 11× 11×   11×    
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;
 
}