return "";
}
- const [sourceSide, sourceStepId, sourcePort] = edge.source.id.split("/");
- const [destSide, destStepId, destPort] = edge.destination.id.split("/");
+ const [, sourceStepId, sourcePort] = edge.source.id.split("/");
+ const [, destStepId, destPort] = edge.destination.id.split("/");
const sourceVertex = containerNode.querySelector(`.node[data-id="${sourceStepId}"] .output-port[data-port-id="${sourcePort}"] .io-port`) as SVGGElement;
const destVertex = containerNode.querySelector(`.node[data-id="${destStepId}"] .input-port[data-port-id="${destPort}"] .io-port`) as SVGGElement;
const ns = "http://www.w3.org/2000/svg";
const edge = document.createElementNS(ns, "g");
- const [sourceSide, sourceStepId, sourcePort] = (connectionIDs.source || "//").split("/");
- const [destSide, destStepId, destPort] = (connectionIDs.destination || "//").split("/");
+ const [, sourceStepId, sourcePort] = (connectionIDs.source || "//").split("/");
+ const [, destStepId, destPort] = (connectionIDs.destination || "//").split("/");
edge.classList.add("edge");
if (sourceStepId) {
* If there is a missing sbg:x or sbg:y property on any node model,
* graph should be arranged to avoid random placement.
*/
- let arrangeNecessary = false;
-
let nodeTemplate = "";
for (const node of nodes) {
const patched = GraphNode.patchModelPorts(node);
- const missingX = isNaN(parseInt(patched.customProps["sbg:x"], 10));
- const missingY = isNaN(parseInt(patched.customProps["sbg:y"], 10));
-
- if (missingX || missingY) {
- arrangeNecessary = true;
- }
-
nodeTemplate += GraphNode.makeTemplate(patched);
-
}
this.workflow.innerHTML += nodeTemplate;
}
private onDelete(ev: KeyboardEvent) {
- if (ev.which !== 8 && ev.which !== 46 || !(ev.target instanceof SVGElement)) {
+ if ((ev.which !== 8 && ev.which !== 46) || !(ev.target instanceof SVGElement)) {
return;
}
const target = ev.target as SVGGElement;
let tipEl: SVGGElement;
- const onMouseMove = ((ev: MouseEvent) => {
+ const onMouseMove = (ev: MouseEvent) => {
const coords = this.workflow.transformScreenCTMtoCanvas(ev.clientX, ev.clientY);
tipEl.setAttribute("x", String(coords.x));
tipEl.setAttribute("y", String(coords.y - 16));
- }).bind(this);
+ };
- const onMouseLeave = ((ev: MouseEvent) => {
+ const onMouseLeave = (ev: MouseEvent) => {
tipEl.remove();
target.removeEventListener("mousemove", onMouseMove);
target.removeEventListener("mouseleave", onMouseLeave)
- }).bind(this);
+ };
this.modelListener = this.workflow.model.on("connection.remove", (source, destination) => {
if (!tipEl) return;
private updateEdge(fromX: number, fromY: number, toX: number, toY: number): void {
const subEdges = this.edgeGroup!.children as HTMLCollectionOf<SVGPathElement>;
- for (let subEdge of <any>subEdges) {
+ for (let subEdge of subEdges as any) {
const path = Workflow.makeConnectionPath(
fromX,
let element: SVGElement | undefined;
- if (element = this.workflow.findParent(target, "node")) {
+ if ((element = this.workflow.findParent(target, "node"))) {
this.selectNode(element);
this.selection.set(element.getAttribute("data-connection-id")!, "node");
this.emitChange(element);
- } else if (element = this.workflow.findParent(target, "edge")) {
+ } else if ((element = this.workflow.findParent(target, "edge"))) {
this.selectEdge(element);
const cid = [
element.getAttribute("data-source-connection"),
const selected = Array.from(this.root.querySelectorAll(selector));
target = ev.target as HTMLElement;
while (target) {
+ // eslint-disable-next-line
if (selected.find(el => el === target)) {
break;
}
} else {
// node still has parent elements
const {e, f} = node.transform.baseVal.getItem(0).matrix;
- return getPosition(<SVGGElement>node.parentNode, e + addE, f + addF);
+ return getPosition(node.parentNode as SVGGElement, e + addE, f + addF);
}
};
};
public static escapeHTML(source: string): string {
- return String(source).replace(/[&<>"'\/]/g, s => HtmlUtils.entityMap[s]);
+ return String(source).replace(/[&<>"'/]/g, s => HtmlUtils.entityMap[s]);
}
}