1 import {StepModel} from "cwlts/models";
2 import {Edge} from "./edge";
3 import {GraphNode} from "./graph-node";
4 import {TemplateParser} from "./template-parser";
6 export class StepNode {
8 private svg: SVGSVGElement;
9 private stepEl: SVGElement;
10 private model: StepModel;
12 constructor(element: SVGElement, stepModel: StepModel) {
14 this.stepEl = element;
15 this.svg = element.ownerSVGElement!;
16 this.model = stepModel;
21 const tpl = GraphNode.makeTemplate(this.model);
22 const el = TemplateParser.parse(tpl)!;
24 this.stepEl.innerHTML = el.innerHTML;
26 // Reposition all edges
27 const incomingEdges = this.svg.querySelectorAll(`.edge[data-destination-node="${this.model.connectionId}"]`);
28 const outgoingEdges = this.svg.querySelectorAll(`.edge[data-source-node="${this.model.connectionId}"`);
30 for (const edge of [...Array.from(incomingEdges), ...Array.from(outgoingEdges)]) {
31 Edge.spawnBetweenConnectionIDs(
32 this.svg.querySelector(".workflow") as SVGGElement,
33 edge.getAttribute("data-source-connection")!,
34 edge.getAttribute("data-destination-connection")!
38 console.log("Should redraw input port", incomingEdges);