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

38 lines
969 B
JavaScript
Raw Normal View History

'use strict';
var inherits = require('inherits');
var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor');
var is = require('../../../util/ModelUtil').is;
/**
* BPMN specific create data object behavior
*/
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);
module.exports = CreateDataObjectBehavior;