2018-04-02 19:01:53 +00:00
|
|
|
import { is } from '../../../util/ModelUtil';
|
2015-05-08 13:27:39 +00:00
|
|
|
|
2016-05-02 06:57:12 +00:00
|
|
|
var COLLAB_ERR_MSG = 'flow elements must be children of pools/participants',
|
|
|
|
PROCESS_ERR_MSG = 'participants cannot be pasted onto a non-empty process diagram';
|
2015-05-08 13:27:39 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
|
|
|
|
export default function ModelingFeedback(eventBus, tooltips, translate) {
|
2015-05-08 13:27:39 +00:00
|
|
|
|
2016-05-02 06:57:12 +00:00
|
|
|
function showError(position, message, timeout) {
|
2015-05-08 13:27:39 +00:00
|
|
|
tooltips.add({
|
|
|
|
position: {
|
|
|
|
x: position.x + 5,
|
|
|
|
y: position.y + 5
|
|
|
|
},
|
|
|
|
type: 'error',
|
2016-05-02 06:57:12 +00:00
|
|
|
timeout: timeout || 2000,
|
2015-05-08 13:27:39 +00:00
|
|
|
html: '<div>' + message + '</div>'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
eventBus.on([ 'shape.move.rejected', 'create.rejected' ], function(event) {
|
|
|
|
var context = event.context,
|
|
|
|
shape = context.shape,
|
|
|
|
target = context.target;
|
|
|
|
|
|
|
|
if (is(target, 'bpmn:Collaboration') && is(shape, 'bpmn:FlowNode')) {
|
2016-04-26 13:04:24 +00:00
|
|
|
showError(event, translate(COLLAB_ERR_MSG));
|
2015-05-08 13:27:39 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-04-26 13:04:24 +00:00
|
|
|
eventBus.on([ 'elements.paste.rejected' ], function(event) {
|
|
|
|
var context = event.context,
|
|
|
|
position = context.position,
|
|
|
|
target = context.target;
|
|
|
|
|
|
|
|
if (is(target, 'bpmn:Collaboration')) {
|
|
|
|
showError(position, translate(COLLAB_ERR_MSG));
|
|
|
|
}
|
2016-05-02 06:57:12 +00:00
|
|
|
|
|
|
|
if (is(target, 'bpmn:Process')) {
|
|
|
|
showError(position, translate(PROCESS_ERR_MSG), 3000);
|
|
|
|
}
|
2016-04-26 13:04:24 +00:00
|
|
|
});
|
2015-05-08 13:27:39 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
ModelingFeedback.$inject = [
|
|
|
|
'eventBus',
|
|
|
|
'tooltips',
|
|
|
|
'translate'
|
|
|
|
];
|