2018-04-02 19:01:53 +00:00
|
|
|
import inherits from 'inherits';
|
2015-10-06 10:33:21 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
|
|
|
|
|
|
|
import { is } from '../../../util/ModelUtil';
|
2015-10-06 10:33:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* BPMN specific create data object behavior
|
|
|
|
*/
|
2018-04-02 19:01:53 +00:00
|
|
|
export default function CreateDataObjectBehavior(eventBus, bpmnFactory, moddle) {
|
2015-10-06 10:33:21 +00:00
|
|
|
|
|
|
|
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') {
|
2015-10-06 10:33:21 +00:00
|
|
|
|
|
|
|
// create a DataObject every time a DataObjectReference is created
|
2016-01-25 20:17:27 +00:00
|
|
|
var dataObject = bpmnFactory.create('bpmn:DataObject');
|
2015-10-06 10:33:21 +00:00
|
|
|
|
|
|
|
// set the reference to the DataObject
|
2016-01-25 20:17:27 +00:00
|
|
|
shape.businessObject.dataObjectRef = dataObject;
|
2015-10-06 10:33:21 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
CreateDataObjectBehavior.$inject = [
|
|
|
|
'eventBus',
|
|
|
|
'bpmnFactory',
|
|
|
|
'moddle'
|
|
|
|
];
|
2015-10-06 10:33:21 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
inherits(CreateDataObjectBehavior, CommandInterceptor);
|