Skip to content

Commit

Permalink
[#439, #444, #474] - Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kasmadei authored and blcham committed Jul 8, 2024
1 parent c548c9a commit 26bd38e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 13 deletions.
3 changes: 2 additions & 1 deletion public/locales/cs/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
17 changes: 14 additions & 3 deletions src/components/dashboard/content/list/FaultTreeOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -26,6 +27,7 @@ const FaultTreeOverview = () => {
const [contextMenuAnchor, setContextMenuAnchor] = useState<ElementContextMenuAnchor>(contextMenuDefaultAnchor);
const [createFaultTreeDialogOpen, setCreateFaultTreeDialogOpen] = useState<boolean>(false);
const [selectedSystem] = useSelectedSystemSummaries();
const isTreeCreationDisabled = !selectedSystem;

useEffect(() => {
const storedView = localStorage.getItem(SELECTED_VIEW) as ViewType;
Expand Down Expand Up @@ -68,9 +70,18 @@ const FaultTreeOverview = () => {
<Box flexDirection="column">
<Box display="flex" flexDirection="row-reverse">
<OverviewTypeToggler selectedView={selectedView} toggleView={toggleView} />
<Button variant="contained" onClick={handleDialogOpen} sx={{ height: 36 }}>
{t("create.tree")}
</Button>
<Tooltip title={isTreeCreationDisabled ? t("create.systemRequired") : ""}>
<span>
<Button
variant="contained"
onClick={handleDialogOpen}
disabled={isTreeCreationDisabled}
sx={{ height: 36 }}
>
{t("create.tree")}
</Button>
</span>
</Tooltip>
</Box>

{selectedView === "table" ? (
Expand Down
2 changes: 1 addition & 1 deletion src/components/editor/faultTree/canvas/EditorCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const FaultEventMenu = ({ shapeToolData, onEventUpdated, refreshTree, rootIri }:

const [snsOperationalFailureRate, setSnsOperationalFailureRate] = useState<number | undefined>(undefined);
const [snsPredictedFailureRate, setSnsPredictedFailureRate] = useState<number | undefined>(undefined);
const [snsManuallyDefinedFailureRate, setSnsManuallyDefinedFailureRate] = useState<number | undefined>(undefined);
const [basicManuallyDefinedFailureRate, setBasicManuallyDefinedFailureRate] = useState<number | undefined>(undefined);
const [externalManuallyDefinedFailureRate, setExternalManuallyDefinedFailureRate] = useState<number | undefined>(
undefined,
);
Expand Down Expand Up @@ -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 {
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 26bd38e

Please sign in to comment.