StartEvent.js 2.4 KB

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