From 9f667b1a791a961f65b8e898f2d3c250008b651e Mon Sep 17 00:00:00 2001 From: Kiryl Koniukh <49252228+Kasmadei@users.noreply.github.com> Date: Sat, 18 May 2024 16:06:53 +0200 Subject: [PATCH] Icon show only for isReference true --- src/components/editor/faultTree/shapes/RenderTree.tsx | 8 ++++++++ .../editor/faultTree/shapes/shapesDefinitions.tsx | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/editor/faultTree/shapes/RenderTree.tsx b/src/components/editor/faultTree/shapes/RenderTree.tsx index 74a436a1..52d99eea 100644 --- a/src/components/editor/faultTree/shapes/RenderTree.tsx +++ b/src/components/editor/faultTree/shapes/RenderTree.tsx @@ -13,6 +13,9 @@ import { } from "@components/editor/faultTree/shapes/constants"; import { getNodeWidthForText } from "@utils/treeUtils"; +const referenceIcon = + "M3.9 7c0-1.71 1.39-3.1 3.1-3.1h4V2H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1M8 8h8v-2H8zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V12h4c2.76 0 5-2.24 5-5s-2.24-5-5-5"; + const renderLink = (container, source, target, shouldHighlight) => { // @ts-ignore const link = Link.create(source, target); @@ -33,10 +36,15 @@ const highlightCheck = (path, iri) => { const renderTree = async (container, node, parentShape = null, pathsToHighlight) => { const shouldHighlight = pathsToHighlight ? highlightCheck(pathsToHighlight, node.iri) : false; + // render node shape let nodeShape = createShape(node); nodeShape.addTo(container); + if (node.isReference && node.eventType === EventType.EXTERNAL) { + nodeShape.attr("icon/d", referenceIcon); + } + if (node.eventType === EventType.INTERMEDIATE) { // @ts-ignore nodeShape.gate(node.gateType.toLowerCase()); diff --git a/src/components/editor/faultTree/shapes/shapesDefinitions.tsx b/src/components/editor/faultTree/shapes/shapesDefinitions.tsx index 195bd37f..c8d2efc8 100644 --- a/src/components/editor/faultTree/shapes/shapesDefinitions.tsx +++ b/src/components/editor/faultTree/shapes/shapesDefinitions.tsx @@ -195,7 +195,7 @@ export const ExternalEvent = Event.define( cursor: "pointer", }, icon: { - d: "M3.9 7c0-1.71 1.39-3.1 3.1-3.1h4V2H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1M8 8h8v-2H8zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V12h4c2.76 0 5-2.24 5-5s-2.24-5-5-5", + d: "", stroke: "none", fill: MAIN_EVENT_BODY_COLOR, },