UNPKG

@logicflow/extension

Version:
219 lines (218 loc) 8.11 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@logicflow/core"); var _1 = require("."); var group_1 = require("../../../materials/group"); // 泳道 var LaneModel = /** @class */ (function (_super) { __extends(LaneModel, _super); function LaneModel() { return _super !== null && _super.apply(this, arguments) || this; } LaneModel.prototype.initNodeData = function (data) { data.properties = __assign(__assign({}, data.properties), { processRef: '', panels: ['processRef'] }); _super.prototype.initNodeData.call(this, data); if (data.width) { this.width = data.width; } if (data.height) { this.height = data.height; } if (data.properties) { this.properties = __assign(__assign({}, this.properties), data.properties); } this.draggable = false; this.resizable = true; this.zIndex = 1; this.toJSON = _1.laneToJSON; }; LaneModel.prototype.changeAttribute = function (_a) { var width = _a.width, height = _a.height, x = _a.x, y = _a.y; if (width) this.width = width; if (height) this.height = height; if (x) this.x = x; if (y) this.y = y; }; return LaneModel; }(group_1.GroupNodeModel)); var LaneView = /** @class */ (function (_super) { __extends(LaneView, _super); function LaneView() { return _super !== null && _super.apply(this, arguments) || this; } LaneView.prototype.getOperateIcon = function () { var model = this.props.model; var isSelected = model.isSelected; if (!isSelected) { return null; } return [this.addAboveIcon(), this.addBelowIcon(), this.deleteIcon()]; }; LaneView.prototype.addAboveIcon = function () { var _this = this; var _a = this.props.model, x = _a.x, y = _a.y, width = _a.width, height = _a.height, id = _a.id; return (0, core_1.h)('g', { cursor: 'pointer', onClick: function () { var groupId = _this.props.graphModel.group.nodeGroupMap.get(id); if (groupId) { var groupModel = _this.props.graphModel.getNodeModelById(groupId); if (groupModel) { ; groupModel.addChildAbove({ x: x, y: y, width: width, height: height, }); } } }, }, [ (0, core_1.h)('rect', { height: 7, width: 20, strokeWidth: 1, fill: '#fff', stroke: '#000', strokeDasharray: '3 3', x: x + width / 2 + 15, y: y - height / 2 + 3, }), (0, core_1.h)('rect', { height: 10, width: 20, strokeWidth: 1, fill: '#fff', stroke: '#000', x: x + width / 2 + 15, y: y - height / 2 + 10, }), ]); }; LaneView.prototype.addBelowIcon = function () { var _this = this; var _a = this.props.model, x = _a.x, y = _a.y, width = _a.width, height = _a.height, id = _a.id; return (0, core_1.h)('g', { cursor: 'pointer', onClick: function () { var groupId = _this.props.graphModel.group.nodeGroupMap.get(id); if (groupId) { var groupModel = _this.props.graphModel.getNodeModelById(groupId); if (groupModel) { ; groupModel.addChildBelow({ x: x, y: y, width: width, height: height, }); } } }, }, [ (0, core_1.h)('rect', { height: 7, width: 20, strokeWidth: 1, fill: '#fff', stroke: '#000', strokeDasharray: '3 3', x: x + width / 2 + 15, y: y - height / 2 + 32 + 5, }), (0, core_1.h)('rect', { height: 10, width: 20, strokeWidth: 1, fill: '#fff', stroke: '#000', x: x + width / 2 + 15, y: y - height / 2 + 2.5 + 20 + 5, }), ]); }; LaneView.prototype.deleteIcon = function () { var _this = this; var _a = this.props.model, x = _a.x, y = _a.y, width = _a.width, height = _a.height, id = _a.id; return (0, core_1.h)('g', { cursor: 'pointer', onClick: function () { var groupId = _this.props.graphModel.group.nodeGroupMap.get(id); if (groupId) { var groupModel = _this.props.graphModel.getNodeModelById(groupId); groupModel.deleteChild(id); } }, }, [ (0, core_1.h)('rect', { height: 20, width: 20, rx: 2, ry: 2, strokeWidth: 1, fill: 'transparent', stroke: 'transparent', x: x + width / 2 + 14, y: y - height / 2 + 50, }), (0, core_1.h)('svg', { transform: 'translate(1.000000, 1.000000)', // fill: '#3C96FE', x: x + width / 2 + 14, y: y - height / 2 + 50, width: 20, height: 20, }, [ (0, core_1.h)('path', { 'pointer-events': 'none', d: 'M15.3,1.4 L12.6,1.4 L12.6,0 L5.4,0 L5.4,1.4 L0,1.4 L0,2.8 L2,2.8 L2,17.3 C2,17.6865993 2.31340068,18 2.7,18 L15.3,18 C15.6865993,18 16,17.6865993 16,17.3 L16,2.8 L18,2.8 L18,1.4 L15.3,1.4 Z M14.6,16.6 L3.4,16.6 L3.4,2.8 L14.6,2.8 L14.6,16.6 Z', }), (0, core_1.h)('path', { 'pointer-events': 'none', d: 'M6,5.4 L7.4,5.4 L7.4,14.4 L6,14.4 L6,5.4 Z M10.6,5.4 L12,5.4 L12,14.4 L10.6,14.4 L10.6,5.4 Z', }), ]), ]); }; LaneView.prototype.getResizeShape = function () { return (0, core_1.h)('g', {}, [_super.prototype.getResizeShape.call(this), this.getOperateIcon()]); }; return LaneView; }(group_1.GroupNode)); var LaneNode = { type: 'lane', view: LaneView, model: LaneModel, }; exports.default = LaneNode;