StartEvent.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. Object.defineProperty(exports, "__esModule", { value: true });
  16. exports.StartEventView = exports.StartEventModel = void 0;
  17. var core_1 = require("@logicflow/core");
  18. var getBpmnId_1 = require("../getBpmnId");
  19. var StartEventModel = /** @class */ (function (_super) {
  20. __extends(StartEventModel, _super);
  21. function StartEventModel(data, graphModel) {
  22. var _this = this;
  23. if (!data.id) {
  24. data.id = "Event_" + getBpmnId_1.getBpmnId();
  25. }
  26. if (!data.text) {
  27. data.text = '';
  28. }
  29. if (data.text && typeof data.text === 'string') {
  30. data.text = {
  31. value: data.text,
  32. x: data.x,
  33. y: data.y + 40,
  34. };
  35. }
  36. // fix: 不能直接全部加,会导致下载后再次上传,位置错误。
  37. // data.text.y += 40;
  38. _this = _super.call(this, data, graphModel) || this;
  39. return _this;
  40. }
  41. StartEventModel.prototype.setAttributes = function () {
  42. this.r = 18;
  43. };
  44. StartEventModel.prototype.getConnectedTargetRules = function () {
  45. var rules = _super.prototype.getConnectedTargetRules.call(this);
  46. var notAsTarget = {
  47. message: '起始节点不能作为边的终点',
  48. validate: function () { return false; },
  49. };
  50. rules.push(notAsTarget);
  51. return rules;
  52. };
  53. StartEventModel.extendKey = 'StartEventModel';
  54. return StartEventModel;
  55. }(core_1.CircleNodeModel));
  56. exports.StartEventModel = StartEventModel;
  57. var StartEventView = /** @class */ (function (_super) {
  58. __extends(StartEventView, _super);
  59. function StartEventView() {
  60. return _super !== null && _super.apply(this, arguments) || this;
  61. }
  62. StartEventView.extendKey = 'StartEventNode';
  63. return StartEventView;
  64. }(core_1.CircleNode));
  65. exports.StartEventView = StartEventView;
  66. var StartEvent = {
  67. type: 'bpmn:startEvent',
  68. view: StartEventView,
  69. model: StartEventModel,
  70. };
  71. exports.default = StartEvent;