Skip to content

Commit

Permalink
Schematic description and stock (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kasmadei authored May 30, 2024
1 parent c2643e6 commit 9fc4106
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
6 changes: 4 additions & 2 deletions public/locales/cs/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
"lastModified": "Poslední úprava",
"lastEditor": "Poslední editor",
"status": "Stav",
"edit": "Upravit"
"edit": "Upravit",
"created": "Vytvořeno"
},
"faultEventMenu": {
"criticality": "Kritičnost",
Expand All @@ -91,7 +92,8 @@
"ataSystem": "ATA systém",
"partNumber": "Číslo součásti",
"stock": "Zásoba",
"quantity": "Množství"
"quantity": "Množství",
"schematicDesignation": "Schématické označení"
},
"appBar": {
"selectSystemPlaceholder": "Vyberte systém"
Expand Down
6 changes: 4 additions & 2 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
"lastModified": "Last modified",
"lastEditor": "Last editor",
"status": "Status",
"edit": "Edit"
"edit": "Edit",
"created": "Created"
},
"faultEventMenu": {
"criticality": "Criticality",
Expand All @@ -91,7 +92,8 @@
"ataSystem": "ATA System",
"partNumber": "Part number",
"stock": "Stock",
"quantity": "Quantity"
"quantity": "Quantity",
"schematicDesignation": "Schematic designation"
},
"appBar": {
"selectSystemPlaceholder": "Select system"
Expand Down
23 changes: 20 additions & 3 deletions src/components/editor/faultTree/menu/faultEvent/FaultEventMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const FaultEventMenu = ({ shapeToolData, onEventUpdated, refreshTree, rootIri }:
const [partNumber, setPartNumber] = useState<string | undefined>(undefined);
const [stock, setStock] = useState<string | undefined>(undefined);
const [quantity, setQuantity] = useState<number | undefined>(undefined);
const [schematicDesignation, setSchematicDesignation] = useState<string | undefined>(undefined);

const handleFailureModeClicked = (failureMode: FailureMode) => {
setFailureModeOverview(failureMode);
Expand Down Expand Up @@ -68,19 +69,29 @@ const FaultEventMenu = ({ shapeToolData, onEventUpdated, refreshTree, rootIri }:
setAtaSystem(undefined);
}

if (filteredPartNumber.length === 1 && filteredPartNumber[0].partNumber && filteredPartNumber[0].stock) {
if (filteredPartNumber.length === 1 && filteredPartNumber[0].partNumber) {
setPartNumber(filteredPartNumber[0].partNumber);
setStock(filteredPartNumber[0].stock);
} else {
setPartNumber(undefined);
setStock(undefined);
}

if (shapeToolData?.supertypes?.behavior?.item?.quantity) {
setQuantity(shapeToolData?.supertypes?.behavior?.item?.quantity);
} else {
setQuantity(undefined);
}

if (shapeToolData?.supertypes?.behavior?.item?.stock) {
setStock(shapeToolData?.supertypes?.behavior?.item?.stock);
} else {
setStock(undefined);
}

if (shapeToolData?.supertypes?.behavior?.item?.schematicDesignation) {
setSchematicDesignation(shapeToolData?.supertypes?.behavior?.item?.schematicDesignation);
} else {
setSchematicDesignation(undefined);
}
}, [shapeToolData]);

const basedFailureRate = shapeToolData?.supertypes?.supertypes?.hasFailureRate?.estimate?.value;
Expand Down Expand Up @@ -213,6 +224,12 @@ const FaultEventMenu = ({ shapeToolData, onEventUpdated, refreshTree, rootIri }:
<span className={classes.label}>{t("faultEventMenu.quantity")}:</span> {quantity}
</Typography>
)}
{schematicDesignation && (
<Typography>
<span className={classes.label}>{t("faultEventMenu.schematicDesignation")}:</span>{" "}
{schematicDesignation}
</Typography>
)}
</Box>

<EventFailureModeList onFailureModeClick={handleFailureModeClicked} />
Expand Down
3 changes: 3 additions & 0 deletions src/models/eventModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const ctx = {
editor: VocabularyUtils.PREFIX + "editor",
username: VocabularyUtils.PREFIX + "username",
estimate: VocabularyUtils.PREFIX + "has-estimate",
schematicDesignation: VocabularyUtils.PREFIX + "schematic-designation",
};

export const CONTEXT = Object.assign({}, ctx, ABSTRACT_CONTEXT, FAILURE_MODE_CONTEXT, RECTANGLE_CONTEXT);
Expand Down Expand Up @@ -95,6 +96,8 @@ export interface FaultEvent extends AbstractModel {
supertypes?: {
ataCode?: string;
};
stock?: string;
schematicDesignation?: string;
};
};
hasFailureRate?: {
Expand Down

0 comments on commit 9fc4106

Please sign in to comment.