ModelingFeedback.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { is } from '../../../util/ModelUtil';
  2. var COLLAB_ERR_MSG = 'flow elements must be children of pools/participants',
  3. PROCESS_ERR_MSG = 'participants cannot be pasted onto a non-empty process diagram';
  4. export default function ModelingFeedback(eventBus, tooltips, translate) {
  5. function showError(position, message, timeout) {
  6. tooltips.add({
  7. position: {
  8. x: position.x + 5,
  9. y: position.y + 5
  10. },
  11. type: 'error',
  12. timeout: timeout || 2000,
  13. html: '<div>' + message + '</div>'
  14. });
  15. }
  16. eventBus.on([ 'shape.move.rejected', 'create.rejected' ], function(event) {
  17. var context = event.context,
  18. shape = context.shape,
  19. target = context.target;
  20. if (is(target, 'bpmn:Collaboration') && is(shape, 'bpmn:FlowNode')) {
  21. showError(event, translate(COLLAB_ERR_MSG));
  22. }
  23. });
  24. eventBus.on([ 'elements.paste.rejected' ], function(event) {
  25. var context = event.context,
  26. position = context.position,
  27. target = context.target;
  28. if (is(target, 'bpmn:Collaboration')) {
  29. showError(position, translate(COLLAB_ERR_MSG));
  30. }
  31. if (is(target, 'bpmn:Process')) {
  32. showError(position, translate(PROCESS_ERR_MSG), 3000);
  33. }
  34. });
  35. }
  36. ModelingFeedback.$inject = [
  37. 'eventBus',
  38. 'tooltips',
  39. 'translate'
  40. ];