Files
bpmn-js/lib/features/modeling/behavior/ModelingFeedback.js
Ricardo Matias c586c908b2 feat(ModelingFeedback): add tooltip when pasting is disallowed
Only in the case of pasting outside of collaboration.

Closes camunda/camunda-modeler#252
2016-04-29 16:19:09 +02:00

46 lines
1.1 KiB
JavaScript

'use strict';
var is = require('../../../util/ModelUtil').is;
var COLLAB_ERR_MSG = 'flow elements must be children of pools/participants';
function ModelingFeedback(eventBus, tooltips, translate) {
function showError(position, message) {
tooltips.add({
position: {
x: position.x + 5,
y: position.y + 5
},
type: 'error',
timeout: 2000,
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')) {
showError(event, translate(COLLAB_ERR_MSG));
}
});
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));
}
});
}
ModelingFeedback.$inject = [ 'eventBus', 'tooltips', 'translate' ];
module.exports = ModelingFeedback;