bpmn-js/lib/features/modeling/behavior/CreateDataObjectBehavior.js

38 lines
923 B
JavaScript
Raw Normal View History

import inherits from 'inherits';
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
import { is } from '../../../util/ModelUtil';
/**
* BPMN specific create data object behavior
*/
export default function CreateDataObjectBehavior(eventBus, bpmnFactory, moddle) {
CommandInterceptor.call(this, eventBus);
this.preExecute('shape.create', function(event) {
var context = event.context,
shape = context.shape;
2016-01-25 20:17:27 +00:00
if (is(shape, 'bpmn:DataObjectReference') && shape.type !== 'label') {
// create a DataObject every time a DataObjectReference is created
2016-01-25 20:17:27 +00:00
var dataObject = bpmnFactory.create('bpmn:DataObject');
// set the reference to the DataObject
2016-01-25 20:17:27 +00:00
shape.businessObject.dataObjectRef = dataObject;
}
});
}
CreateDataObjectBehavior.$inject = [
'eventBus',
'bpmnFactory',
'moddle'
];
inherits(CreateDataObjectBehavior, CommandInterceptor);