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

RSDEV-279 Additional subsample count label #60

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
19 changes: 13 additions & 6 deletions src/main/webapp/ui/src/Inventory/Subsample/Fields/Quantity.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
.
</>
)}
</Link>
</Typography>
)}
Expand Down
40 changes: 37 additions & 3 deletions src/main/webapp/ui/src/Inventory/components/Fields/Sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -15,16 +18,47 @@ export default function SampleField<
FieldOwner: HasUneditableFields<Fields>
>({ fieldOwner }: {| fieldOwner: FieldOwner |}): Node {
const sample = fieldOwner.fieldValues.sample;
const { useNavigate } = React.useContext(NavigateContext);
const navigate = useNavigate();

return (
<FormField
value={void 0}
label="Parent Sample"
disabled
renderInput={() => (
<Box>
<RecordLink record={sample} />
</Box>
<>
<Box>
<RecordLink record={sample} />
</Box>
{sample.globalId && (
<Typography variant="caption">
<Link
href={`/inventory/search?parentGlobalId=${sample.globalId}`}
onClick={(e) => {
e.preventDefault();
if (sample.globalId)
navigate(
`/inventory/search?parentGlobalId=${sample.globalId}`
);
}}
>
{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}
.
</>
)}
</Link>
</Typography>
)}
</>
)}
/>
);
Expand Down
Loading