EndEvent.js 3.3 KB

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