EndEvent.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. var __extends = (this && this.__extends) || (function () {
  2. var extendStatics = function (d, b) {
  3. extendStatics = Object.setPrototypeOf ||
  4. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6. return extendStatics(d, b);
  7. };
  8. return function (d, b) {
  9. extendStatics(d, b);
  10. function __() { this.constructor = d; }
  11. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12. };
  13. })();
  14. var __assign = (this && this.__assign) || function () {
  15. __assign = Object.assign || function(t) {
  16. for (var s, i = 1, n = arguments.length; i < n; i++) {
  17. s = arguments[i];
  18. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  19. t[p] = s[p];
  20. }
  21. return t;
  22. };
  23. return __assign.apply(this, arguments);
  24. };
  25. import { CircleNode, CircleNodeModel, h } from '@logicflow/core';
  26. import { getBpmnId } from '../getBpmnId';
  27. var EndEventModel = /** @class */ (function (_super) {
  28. __extends(EndEventModel, _super);
  29. function EndEventModel(data, graphModel) {
  30. var _this = this;
  31. if (!data.id) {
  32. data.id = "Event_" + getBpmnId();
  33. }
  34. if (!data.text) {
  35. data.text = '';
  36. }
  37. if (data.text && typeof data.text === 'string') {
  38. data.text = {
  39. value: data.text,
  40. x: data.x,
  41. y: data.y + 40,
  42. };
  43. }
  44. _this = _super.call(this, data, graphModel) || this;
  45. return _this;
  46. }
  47. EndEventModel.prototype.setAttributes = function () {
  48. this.r = 18;
  49. };
  50. EndEventModel.prototype.getConnectedSourceRules = function () {
  51. var rules = _super.prototype.getConnectedSourceRules.call(this);
  52. var notAsSource = {
  53. message: '结束节点不能作为边的起点',
  54. validate: function () { return false; },
  55. };
  56. rules.push(notAsSource);
  57. return rules;
  58. };
  59. EndEventModel.extendKey = 'EndEventModel';
  60. return EndEventModel;
  61. }(CircleNodeModel));
  62. var EndEventView = /** @class */ (function (_super) {
  63. __extends(EndEventView, _super);
  64. function EndEventView() {
  65. return _super !== null && _super.apply(this, arguments) || this;
  66. }
  67. EndEventView.prototype.getAnchorStyle = function () {
  68. return {
  69. visibility: 'hidden',
  70. };
  71. };
  72. EndEventView.prototype.getShape = function () {
  73. var model = this.props.model;
  74. var style = model.getNodeStyle();
  75. var x = model.x, y = model.y, r = model.r;
  76. var outCircle = _super.prototype.getShape.call(this);
  77. return h('g', {}, outCircle, h('circle', __assign(__assign({}, style), { cx: x, cy: y, r: r - 5 })));
  78. };
  79. EndEventView.extendKey = 'EndEventView';
  80. return EndEventView;
  81. }(CircleNode));
  82. var EndEvent = {
  83. type: 'bpmn:endEvent',
  84. view: EndEventView,
  85. model: EndEventModel,
  86. };
  87. export { EndEventView, EndEventModel };
  88. export default EndEvent;