2018-04-02 19:01:53 +00:00
|
|
|
import inherits from 'inherits';
|
2014-12-07 12:08:50 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import { is } from '../../../util/ModelUtil';
|
2014-12-07 12:08:50 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
2014-12-07 12:08:50 +00:00
|
|
|
|
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
export default function AppendBehavior(eventBus, elementFactory, bpmnRules) {
|
2015-04-28 11:57:03 +00:00
|
|
|
|
|
|
|
CommandInterceptor.call(this, eventBus);
|
|
|
|
|
|
|
|
// assign correct shape position unless already set
|
|
|
|
|
|
|
|
this.preExecute('shape.append', function(context) {
|
|
|
|
|
|
|
|
var source = context.source,
|
|
|
|
shape = context.shape;
|
2014-12-07 12:08:50 +00:00
|
|
|
|
|
|
|
if (!context.position) {
|
|
|
|
|
2015-04-28 11:57:03 +00:00
|
|
|
if (is(shape, 'bpmn:TextAnnotation')) {
|
2014-12-07 12:08:50 +00:00
|
|
|
context.position = {
|
|
|
|
x: source.x + source.width / 2 + 75,
|
|
|
|
y: source.y - (50) - shape.height / 2
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
context.position = {
|
|
|
|
x: source.x + source.width + 80 + shape.width / 2,
|
|
|
|
y: source.y + source.height / 2
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2015-04-28 11:57:03 +00:00
|
|
|
}, true);
|
2014-12-07 12:08:50 +00:00
|
|
|
}
|
|
|
|
|
2015-04-28 11:57:03 +00:00
|
|
|
inherits(AppendBehavior, CommandInterceptor);
|
2014-12-07 12:08:50 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
AppendBehavior.$inject = [
|
|
|
|
'eventBus',
|
|
|
|
'elementFactory',
|
|
|
|
'bpmnRules'
|
|
|
|
];
|