From 2e774966bbb507ec0a46707f026950f3c9b19cad Mon Sep 17 00:00:00 2001 From: Robert Lamacraft Date: Tue, 9 Jul 2024 14:16:08 +0100 Subject: [PATCH 1/2] Add sibling count to parent sample field --- .../src/Inventory/components/Fields/Sample.js | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/main/webapp/ui/src/Inventory/components/Fields/Sample.js b/src/main/webapp/ui/src/Inventory/components/Fields/Sample.js index 4f41ba66d..a6d723ff1 100644 --- a/src/main/webapp/ui/src/Inventory/components/Fields/Sample.js +++ b/src/main/webapp/ui/src/Inventory/components/Fields/Sample.js @@ -6,6 +6,9 @@ import { type Sample } from "../../../stores/definitions/Sample"; import { RecordLink } from "../RecordLink"; import FormField from "../../../components/Inputs/FormField"; import Box from "@mui/material/Box"; +import Link from "@mui/material/Link"; +import Typography from "@mui/material/Typography"; +import NavigateContext from "../../../stores/contexts/Navigate"; export default function SampleField< Fields: { @@ -15,6 +18,8 @@ export default function SampleField< FieldOwner: HasUneditableFields >({ fieldOwner }: {| fieldOwner: FieldOwner |}): Node { const sample = fieldOwner.fieldValues.sample; + const { useNavigate } = React.useContext(NavigateContext); + const navigate = useNavigate(); return ( ( - - - + <> + + + + {sample.globalId && ( + + { + e.preventDefault(); + if (sample.globalId) + navigate( + `/inventory/search?parentGlobalId=${sample.globalId}` + ); + }} + > + There {sample.subSamplesCount === 2 ? "is" : "are"}{" "} + {sample.subSamplesCount - 1} other{" "} + {sample.subSamplesCount === 2 + ? sample.subSampleAlias.alias + : sample.subSampleAlias.plural} + . + + + )} + )} /> ); From 863c08fcde5d8328f613bf7e00a57f583b85c3aa Mon Sep 17 00:00:00 2001 From: Robert Lamacraft Date: Fri, 12 Jul 2024 15:01:53 +0100 Subject: [PATCH 2/2] Tweak singleton label --- .../Inventory/Subsample/Fields/Quantity.js | 19 +++++++++++++------ .../src/Inventory/components/Fields/Sample.js | 18 ++++++++++++------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/main/webapp/ui/src/Inventory/Subsample/Fields/Quantity.js b/src/main/webapp/ui/src/Inventory/Subsample/Fields/Quantity.js index c6a8e4066..c9631a24f 100644 --- a/src/main/webapp/ui/src/Inventory/Subsample/Fields/Quantity.js +++ b/src/main/webapp/ui/src/Inventory/Subsample/Fields/Quantity.js @@ -162,12 +162,19 @@ function QuantityField< ); }} > - There {parentSample.subSamplesCount === 2 ? "is" : "are"}{" "} - {parentSample.subSamplesCount - 1} other{" "} - {parentSample.subSamplesCount === 2 - ? parentSample.subSampleAlias.alias - : parentSample.subSampleAlias.plural} - . + {parentSample.subSamplesCount === 1 ? ( + `The parent sample only has one ${parentSample.subSampleAlias.alias}.` + ) : ( + <> + There{" "} + {parentSample.subSamplesCount === 2 ? "is" : "are"}{" "} + {parentSample.subSamplesCount - 1} other{" "} + {parentSample.subSamplesCount === 2 + ? parentSample.subSampleAlias.alias + : parentSample.subSampleAlias.plural} + . + + )} )} diff --git a/src/main/webapp/ui/src/Inventory/components/Fields/Sample.js b/src/main/webapp/ui/src/Inventory/components/Fields/Sample.js index a6d723ff1..f3d8aab8f 100644 --- a/src/main/webapp/ui/src/Inventory/components/Fields/Sample.js +++ b/src/main/webapp/ui/src/Inventory/components/Fields/Sample.js @@ -43,12 +43,18 @@ export default function SampleField< ); }} > - There {sample.subSamplesCount === 2 ? "is" : "are"}{" "} - {sample.subSamplesCount - 1} other{" "} - {sample.subSamplesCount === 2 - ? sample.subSampleAlias.alias - : sample.subSampleAlias.plural} - . + {sample.subSamplesCount === 1 ? ( + `The parent sample only has one ${sample.subSampleAlias.alias}.` + ) : ( + <> + There {sample.subSamplesCount === 2 ? "is" : "are"}{" "} + {sample.subSamplesCount - 1} other{" "} + {sample.subSamplesCount === 2 + ? sample.subSampleAlias.alias + : sample.subSampleAlias.plural} + . + + )} )}