diff --git a/src/components/editor/faultTree/Editor.tsx b/src/components/editor/faultTree/Editor.tsx index 6a961371..30094df9 100644 --- a/src/components/editor/faultTree/Editor.tsx +++ b/src/components/editor/faultTree/Editor.tsx @@ -32,6 +32,16 @@ const Editor = ({setAppBarName}: DashboardTitleProps) => { const [highlightedElementView, setHighlightedElementView] = useState(null) const _localContext = useLocalContext({rootEvent: rootEvent, highlightedElementView: highlightedElementView}) + const getRootEvent = () : FaultEvent => { + // @ts-ignore + return _localContext.rootEvent; + } + + const getHighlightedElementView = () => { + // @ts-ignore + return _localContext.highlightedElementView + } + useEffect(() => { if (faultTree) { setAppBarName(faultTree.name) @@ -61,16 +71,15 @@ const Editor = ({setAppBarName}: DashboardTitleProps) => { const [contextMenuAnchor, setContextMenuAnchor] = useState(contextMenuDefaultAnchor) const handleContextMenu = (elementView, evt) => { const elementIri = elementView.model.get(JOINTJS_NODE_MODEL.faultEventIri); - // @ts-ignore - const foundEvent = findEventByIri(elementIri, _localContext.rootEvent); + + const foundEvent = findEventByIri(elementIri, getRootEvent()); setContextMenuSelectedEvent(foundEvent); setContextMenuAnchor({mouseX: evt.pageX, mouseY: evt.pageY,}) } const handleElementPointerClick = (elementView) => { const elementIri = elementView.model.get(JOINTJS_NODE_MODEL.faultEventIri); - // @ts-ignore - const foundEvent = findEventByIri(elementIri, _localContext.rootEvent); + const foundEvent = findEventByIri(elementIri, getRootEvent()); setSidebarSelectedEvent(foundEvent); setHighlightedElementView(elementView); @@ -83,8 +92,8 @@ const Editor = ({setAppBarName}: DashboardTitleProps) => { const handleMoveEvent = (elementView, evt) => { const faultEventIri = elementView.model.get(JOINTJS_NODE_MODEL.faultEventIri); - // @ts-ignore - const movedEvent = findEventByIri(faultEventIri, _localContext.rootEvent); + + const movedEvent = findEventByIri(faultEventIri, getRootEvent()); const rect :Rectangle = movedEvent.rectangle; const size = elementView.model.attributes.size; const position = elementView.model.attributes.position; @@ -104,8 +113,7 @@ const Editor = ({setAppBarName}: DashboardTitleProps) => { elementView.addTools(tools); } const hideHighlightedBorders = () => { - // @ts-ignore - _localContext.highlightedElementView?.removeTools(); + getHighlightedElementView()?.removeTools(); setHighlightedElementView(null); } diff --git a/src/components/editor/faultTree/canvas/EditorCanvas.tsx b/src/components/editor/faultTree/canvas/EditorCanvas.tsx index bcc15d1c..2aec953a 100644 --- a/src/components/editor/faultTree/canvas/EditorCanvas.tsx +++ b/src/components/editor/faultTree/canvas/EditorCanvas.tsx @@ -70,7 +70,6 @@ const EditorCanvas = ({ const divContainer = document.getElementById("jointjs-container"); const paper = new joint.dia.Paper({ - // @ts-ignore el: divContainer, model: graph, width: canvasWidth, @@ -89,7 +88,6 @@ const EditorCanvas = ({ }); setSvgZoom(diagramZoom); - // @ts-ignore paper.on({ 'element:contextmenu': (elementView, evt) => { onElementContextMenu(elementView, evt) diff --git a/src/components/editor/system/Editor.tsx b/src/components/editor/system/Editor.tsx index 70f442fb..68c8b452 100644 --- a/src/components/editor/system/Editor.tsx +++ b/src/components/editor/system/Editor.tsx @@ -45,11 +45,20 @@ const Editor = ({setAppBarName}: DashboardTitleProps) => { setContextMenuAnchor({mouseX: evt.pageX, mouseY: evt.pageY,}) } + const getSystem = () => { + // @ts-ignore + return _localContext.system; + } + + const getHighlightedElementView = () => { + // @ts-ignore + return _localContext.highlightedElementView + } + const handleContextMenu = (elementView, evt) => { const componentIri = elementView.model.get('custom/componentIri'); - // @ts-ignore - const flattenedComponents = flatten([_localContext.system.components]); + const flattenedComponents = flatten([getSystem().components]); const index = findIndex(flattenedComponents, el => el.iri === componentIri); if (index > -1) { setContextMenuSelectedComponent(flattenedComponents[index]); @@ -60,8 +69,7 @@ const Editor = ({setAppBarName}: DashboardTitleProps) => { const handleElementPointerClick = (elementView) => { const componentIri = elementView.model.get('custom/componentIri'); - // @ts-ignore - const flattenedComponents = flatten([_localContext.system.components]); + const flattenedComponents = flatten([getSystem().components]); const index = findIndex(flattenedComponents, el => el.iri === componentIri); if (index > -1) { setSidebarSelectedComponent(flattenedComponents[index]); @@ -82,8 +90,7 @@ const Editor = ({setAppBarName}: DashboardTitleProps) => { elementView.addTools(tools); } const hideHighlightedBorders = () => { - // @ts-ignore - _localContext.highlightedElementView?.removeTools(); + getHighlightedElementView()?.removeTools(); setHighlightedElementView(null); } diff --git a/src/components/editor/system/canvas/EditorCanvas.tsx b/src/components/editor/system/canvas/EditorCanvas.tsx index c4bcfe47..332ff7a8 100644 --- a/src/components/editor/system/canvas/EditorCanvas.tsx +++ b/src/components/editor/system/canvas/EditorCanvas.tsx @@ -55,7 +55,6 @@ const EditorCanvas = ({ const graph = new joint.dia.Graph; const divContainer = document.getElementById("jointjs-system-container"); const paper = new joint.dia.Paper({ - // @ts-ignore el: divContainer, model: graph, width: canvasWidth, @@ -73,7 +72,6 @@ const EditorCanvas = ({ }); setSvgZoom(diagramZoom); - // @ts-ignore paper.on({ 'blank:contextmenu': (evt) => { onBlankContextMenu(evt); diff --git a/src/components/editor/system/menu/component/ComponentEditMenu.tsx b/src/components/editor/system/menu/component/ComponentEditMenu.tsx index 9416d0a0..cd854df8 100644 --- a/src/components/editor/system/menu/component/ComponentEditMenu.tsx +++ b/src/components/editor/system/menu/component/ComponentEditMenu.tsx @@ -38,7 +38,6 @@ const ComponentEditMenu = ({component, onComponentUpdated}: Props) => { useEffect(() => { - // @ts-ignore reset(defaultValues) }, [component]) diff --git a/src/components/editor/system/menu/function/ComponentFunctionsList.tsx b/src/components/editor/system/menu/function/ComponentFunctionsList.tsx index 797e9041..4384d68a 100644 --- a/src/components/editor/system/menu/function/ComponentFunctionsList.tsx +++ b/src/components/editor/system/menu/function/ComponentFunctionsList.tsx @@ -148,7 +148,6 @@ const ComponentFunctionsList = ({ component }) => { }) } - // @ts-ignore return (