mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-01-10 09:05:58 +00:00
7b712d8428
This commit adds the ModelingFeedback component. It hooks into modeling action rejected events and displays error messages to the user. The current behavior is to show an error message when dropping a flow node outside a participant in a collaboration. Related to #203
36 lines
789 B
JavaScript
36 lines
789 B
JavaScript
'use strict';
|
|
|
|
var is = require('../../../util/ModelUtil').is;
|
|
|
|
|
|
function ModelingFeedback(eventBus, tooltips) {
|
|
|
|
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, 'flow elements must be children of pools/participants');
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
|
|
ModelingFeedback.$inject = [ 'eventBus', 'tooltips' ];
|
|
|
|
module.exports = ModelingFeedback; |