IsHorizontalFix.js 1001 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import inherits from 'inherits';
  2. import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
  3. import {
  4. getBusinessObject
  5. } from '../../../util/ModelUtil';
  6. import {
  7. isAny
  8. } from '../util/ModelingUtil';
  9. /**
  10. * A component that makes sure that each created or updated
  11. * Pool and Lane is assigned an isHorizontal property set to true.
  12. *
  13. * @param {EventBus} eventBus
  14. */
  15. export default function IsHorizontalFix(eventBus) {
  16. CommandInterceptor.call(this, eventBus);
  17. var elementTypesToUpdate = [
  18. 'bpmn:Participant',
  19. 'bpmn:Lane'
  20. ];
  21. this.executed([ 'shape.move', 'shape.create', 'shape.resize' ], function(event) {
  22. var bo = getBusinessObject(event.context.shape);
  23. if (isAny(bo, elementTypesToUpdate) && !bo.di.get('isHorizontal')) {
  24. // set attribute directly to avoid modeling#updateProperty side effects
  25. bo.di.set('isHorizontal', true);
  26. }
  27. });
  28. }
  29. IsHorizontalFix.$inject = [ 'eventBus' ];
  30. inherits(IsHorizontalFix, CommandInterceptor);