Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering SNS number and label #648

Merged
merged 4 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/editor/faultTree/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ const Editor = () => {

useEffect(() => {
if (faultTree) {
setAppBarTitle(faultTree.name);
setAppBarTitle(
faultTree?.subSystem?.ataCode ? `${faultTree.name} (${faultTree?.subSystem?.ataCode})` : faultTree.name,
);
setRootEvent(faultTree.manifestingEvent);

if (faultTree.faultEventScenarios) {
Expand Down
30 changes: 23 additions & 7 deletions src/components/editor/faultTree/menu/faultEvent/FaultEventMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ const FaultEventMenu = ({
const [failureModeOverview, setFailureModeOverview] = useState<FailureMode | null>(null);

const [criticality, setCriticality] = useState<string | undefined>(undefined);
const [ataSystem, setAtaSystem] = useState<string | undefined>("");
const [ataCode, setAtaCode] = useState<string | undefined>("");
const [ataNames, setAtaNames] = useState<string[] | undefined>(undefined);
const [partNumber, setPartNumber] = useState<string | undefined>("");
const [stock, setStock] = useState<string | undefined>("");
const [quantity, setQuantity] = useState<number | undefined>(0);
Expand Down Expand Up @@ -213,10 +214,15 @@ const FaultEventMenu = ({
const filteredPartNumber = superTypes.filter((sType) => sType?.partNumber);

if (filteredAtaCode.length === 1 && filteredAtaCode[0].ataCode && filteredAtaCode[0].name) {
const ataSystemString = `${filteredAtaCode[0].ataCode} ${filteredAtaCode[0].name}`;
setAtaSystem(ataSystemString);
setAtaCode(filteredAtaCode[0].ataCode);
const altNames = asArray(filteredAtaCode[0]?.altNames);
if (filteredAtaCode[0].ataCode === filteredAtaCode[0].name) {
if (altNames.length > 0) setAtaNames(altNames);
} else {
setAtaNames([filteredAtaCode[0].name]);
}
} else {
setAtaSystem(undefined);
setAtaCode(undefined);
}

if (filteredPartNumber.length === 1 && filteredPartNumber[0].partNumber) {
Expand Down Expand Up @@ -532,14 +538,24 @@ const FaultEventMenu = ({
{shapeToolData && (
<EventFailureModeProvider eventIri={shapeToolData?.iri}>
<Box>
{(criticality || ataSystem || partNumber || stock || quantity || schematicDesignation) && (
{(criticality || ataCode || partNumber || stock || quantity || schematicDesignation) && (
<Divider className={classes.divider} />
)}
{criticality && <Typography>{propertyWithValue("eventDescription.severity", criticality)}</Typography>}
{ataSystem && (
{ataCode && (
<Typography>
<span className={classes.label}>{t("faultEventMenu.ataSystem")}:</span>
<span className={classes.notEditableValue}>{ataSystem}</span>
<Tooltip
title={
<Typography>
{ataNames.map((n) => {
return <div>{n}</div>;
})}
</Typography>
}
>
<span className={classes.notEditableValue}>{ataCode}</span>
</Tooltip>
</Typography>
)}
{partNumber && (
Expand Down
22 changes: 20 additions & 2 deletions src/components/table/FaultTreeTableBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useTranslation } from "react-i18next";
import useStyles from "./FaultTreeOverviewTable.styles";
import { FaultTree, getFaultTreeCalculationStatus } from "@models/faultTreeModel";
import { extractFragment } from "@services/utils/uriIdentifierUtils";
import { findByIri, formatDate } from "@utils/utils";
import { asArray, findByIri, formatDate } from "@utils/utils";
import { ROUTES, Status } from "@utils/constants";
import { useSelectedSystemSummaries } from "@hooks/useSelectedSystemSummaries";
import { useSystems } from "@hooks/useSystems";
Expand Down Expand Up @@ -57,11 +57,29 @@ const FaultTreeTableBody: FC<FaultTreeTableBodyProps> = ({ faultTrees, handleFau
: theme.main.black;

const editor = faultTree?.editor || faultTree?.creator;

const ataNames = asArray(
faultTree?.subSystem?.name === faultTree?.subSystem?.ataCode
? faultTree?.subSystem?.altNames
: faultTree?.subSystem?.name,
).filter((n) => n);
return (
<TableRow key={rowIndex} className={classes.noBorder}>
<TableCell className={classes.firstColumn}>{faultTree.name}</TableCell>
<TableCell className={classes.tableCell}>{faultTree?.system?.name}</TableCell>
<TableCell className={classes.tableCell}>{faultTree?.subSystem?.name}</TableCell>
<TableCell className={classes.tableCell}>
<Tooltip
title={
<Typography>
{ataNames.map((n) => {
return <div>{n}</div>;
})}
</Typography>
}
>
<Typography>{faultTree?.subSystem?.ataCode}</Typography>
</Tooltip>
</TableCell>
<TableCell style={{ color: syncStatusColor }} className={classes.tableCell}>
{failureRate(
faultTree?.calculatedFailureRate,
Expand Down
1 change: 1 addition & 0 deletions src/models/eventModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export interface FaultEvent extends AbstractModel {
ataCode?: string;
partNumber?: string;
name?: string;
altNames?: string;
};
stock?: string;
schematicDesignation?: string;
Expand Down
2 changes: 2 additions & 0 deletions src/models/faultTreeModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export interface FaultTree extends AbstractModel {
status?: string;
subSystem?: {
name?: string;
ataCode?: string;
altNames?: string;
};
operationalDataFilter: OperationalDataFilter;
}
Expand Down
2 changes: 2 additions & 0 deletions src/models/systemModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { OperationalDataFilter, CONTEXT as FILTER_CONTEXT } from "@models/operat

const ctx = {
name: VocabularyUtils.PREFIX + "name",
altNames: VocabularyUtils.PREFIX + "alt-name",
globalOperationalDataFilter: VocabularyUtils.PREFIX + "has-global-operational-data-filter",
operationalDataFilter: VocabularyUtils.PREFIX + "has-operational-data-filter",
components: VocabularyUtils.PREFIX + "has-part-component",
Expand All @@ -14,6 +15,7 @@ export const CONTEXT = Object.assign({}, ctx, COMPONENT_CONTEXT, ABSTRACT_CONTEX

export interface System extends AbstractModel {
name: string;
altNames: string;
iri?: string;
components?: Component[];
globalOperationalDataFilter: OperationalDataFilter;
Expand Down
Loading