From 26bd38e8689a8c486697811a06b711e486dacc64 Mon Sep 17 00:00:00 2001 From: Kiryl Koniukh <49252228+Kasmadei@users.noreply.github.com> Date: Mon, 8 Jul 2024 17:07:14 +0200 Subject: [PATCH] [#439, #444, #474] - Fixes --- public/locales/cs/translation.json | 3 ++- public/locales/en/translation.json | 3 ++- .../content/list/FaultTreeOverview.tsx | 17 ++++++++++++++--- .../editor/faultTree/canvas/EditorCanvas.tsx | 2 +- .../menu/faultEvent/FaultEventMenu.tsx | 14 +++++++------- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/public/locales/cs/translation.json b/public/locales/cs/translation.json index f03ff258..c762ccfd 100644 --- a/public/locales/cs/translation.json +++ b/public/locales/cs/translation.json @@ -8,7 +8,8 @@ "create": { "system": "Nový systém", "tree": "Nový strom poruch", - "worksheet": "Nový pracovní list FMEA" + "worksheet": "Nový pracovní list FMEA", + "systemRequired": "Výběr systému je vyžadován" }, "newSystemModal": { "title": "Vytvořit systém", diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index b4fb684d..bb6e8248 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -8,7 +8,8 @@ "create": { "system": "New system", "tree": "New Fault tree", - "worksheet": "New FMEA worksheet" + "worksheet": "New FMEA worksheet", + "systemRequired": "A system selection is required" }, "newSystemModal": { "title": "Create System", diff --git a/src/components/dashboard/content/list/FaultTreeOverview.tsx b/src/components/dashboard/content/list/FaultTreeOverview.tsx index ea67730c..ac7b63a3 100644 --- a/src/components/dashboard/content/list/FaultTreeOverview.tsx +++ b/src/components/dashboard/content/list/FaultTreeOverview.tsx @@ -14,6 +14,7 @@ import { Box, Button } from "@mui/material"; import { useTranslation } from "react-i18next"; import { SELECTED_VIEW } from "@utils/constants"; import { useSelectedSystemSummaries } from "@hooks/useSelectedSystemSummaries"; +import Tooltip from "@mui/material/Tooltip"; const FaultTreeOverview = () => { const { t } = useTranslation(); @@ -26,6 +27,7 @@ const FaultTreeOverview = () => { const [contextMenuAnchor, setContextMenuAnchor] = useState(contextMenuDefaultAnchor); const [createFaultTreeDialogOpen, setCreateFaultTreeDialogOpen] = useState(false); const [selectedSystem] = useSelectedSystemSummaries(); + const isTreeCreationDisabled = !selectedSystem; useEffect(() => { const storedView = localStorage.getItem(SELECTED_VIEW) as ViewType; @@ -68,9 +70,18 @@ const FaultTreeOverview = () => { - + + + + + {selectedView === "table" ? ( diff --git a/src/components/editor/faultTree/canvas/EditorCanvas.tsx b/src/components/editor/faultTree/canvas/EditorCanvas.tsx index c63bcb6d..dbeb6833 100644 --- a/src/components/editor/faultTree/canvas/EditorCanvas.tsx +++ b/src/components/editor/faultTree/canvas/EditorCanvas.tsx @@ -140,7 +140,7 @@ const EditorCanvas = ({ "element:contextmenu": (elementView: joint.dia.ElementView, evt: joint.dia.Event) => { onElementContextMenu(elementView, evt); }, - "element:pointerclick": (elementView: joint.dia.ElementView, evt: joint.dia.Event) => { + "element:pointerdown": (elementView: joint.dia.ElementView, evt: joint.dia.Event) => { onElementPointerClick(elementView, evt); }, "element:pointermove": (elementView: joint.dia.ElementView, evt: joint.dia.Event, x: number, y: number) => { diff --git a/src/components/editor/faultTree/menu/faultEvent/FaultEventMenu.tsx b/src/components/editor/faultTree/menu/faultEvent/FaultEventMenu.tsx index d70fd58b..eee52303 100644 --- a/src/components/editor/faultTree/menu/faultEvent/FaultEventMenu.tsx +++ b/src/components/editor/faultTree/menu/faultEvent/FaultEventMenu.tsx @@ -67,7 +67,7 @@ const FaultEventMenu = ({ shapeToolData, onEventUpdated, refreshTree, rootIri }: const [snsOperationalFailureRate, setSnsOperationalFailureRate] = useState(undefined); const [snsPredictedFailureRate, setSnsPredictedFailureRate] = useState(undefined); - const [snsManuallyDefinedFailureRate, setSnsManuallyDefinedFailureRate] = useState(undefined); + const [basicManuallyDefinedFailureRate, setBasicManuallyDefinedFailureRate] = useState(undefined); const [externalManuallyDefinedFailureRate, setExternalManuallyDefinedFailureRate] = useState( undefined, ); @@ -98,7 +98,7 @@ const FaultEventMenu = ({ shapeToolData, onEventUpdated, refreshTree, rootIri }: if (shapeToolData.eventType === EventType.BASIC) { await onEventUpdated({ ...shapeToolData, - probability: snsManuallyDefinedFailureRate, + probability: basicManuallyDefinedFailureRate, selectedEstimate: undefined, }); } else { @@ -121,7 +121,7 @@ const FaultEventMenu = ({ shapeToolData, onEventUpdated, refreshTree, rootIri }: const regex = /^[0-9]*\.?[0-9]*$/; if (regex.test(inputValue)) { if (type === NodeTypeWithManualFailureRate.Sns) { - setSnsManuallyDefinedFailureRate(inputValue); + setBasicManuallyDefinedFailureRate(inputValue); } if (type === NodeTypeWithManualFailureRate.External) { setExternalManuallyDefinedFailureRate(inputValue); @@ -152,7 +152,7 @@ const FaultEventMenu = ({ shapeToolData, onEventUpdated, refreshTree, rootIri }: setSnsOperationalIri(undefined); setSnsPredictedIri(undefined); setExternalManuallyDefinedFailureRate(undefined); - setSnsManuallyDefinedFailureRate(undefined); + setBasicManuallyDefinedFailureRate(undefined); setSelectedRadioButton(RadioButtonType.Predicted); if (shapeToolData?.supertypes?.criticality) { @@ -220,14 +220,14 @@ const FaultEventMenu = ({ shapeToolData, onEventUpdated, refreshTree, rootIri }: setSelectedRadioButton(RadioButtonType.Operational); setPreselectedSelectedRadioButton(RadioButtonType.Operational); } - setSnsManuallyDefinedFailureRate(undefined); + setBasicManuallyDefinedFailureRate(undefined); setExternalManuallyDefinedFailureRate(undefined); } else { // NO SELECTED ESTIMATE => MANUAL IS SELECTED setSelectedRadioButton(RadioButtonType.Manual); setPreselectedSelectedRadioButton(RadioButtonType.Manual); if (shapeToolData?.probability) { - setSnsManuallyDefinedFailureRate(shapeToolData.probability); + setBasicManuallyDefinedFailureRate(shapeToolData.probability); setExternalManuallyDefinedFailureRate(shapeToolData.probability); } } @@ -394,7 +394,7 @@ const FaultEventMenu = ({ shapeToolData, onEventUpdated, refreshTree, rootIri }: className={classes.numberInput} InputLabelProps={{ shrink: false }} variant="outlined" - value={snsManuallyDefinedFailureRate || ""} + value={basicManuallyDefinedFailureRate || ""} onChange={(event) => handleManuallyDefinedFailureRateChange(event, NodeTypeWithManualFailureRate.Sns) }