Skip to content

Commit

Permalink
final tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak committed Jul 19, 2024
1 parent a1db3eb commit dc5a7e9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
26 changes: 24 additions & 2 deletions editor.planx.uk/src/@planx/components/PlanningConstraints/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Accordion from "@mui/material/Accordion";
import AccordionDetails from "@mui/material/AccordionDetails";
import AccordionSummary from "@mui/material/AccordionSummary";
import Box, { BoxProps } from "@mui/material/Box";
import Chip from "@mui/material/Chip";
import Link from "@mui/material/Link";
import List from "@mui/material/List";
import ListItem from "@mui/material/ListItem";
Expand Down Expand Up @@ -218,20 +219,41 @@ function ConstraintListItem({ children, ...props }: ConstraintListItemProps) {
key={`entity-${record.entity}-li`}
dense
disableGutters
sx={{ display: "list-item" }}
sx={{
display: "list-item",
color: props.inaccurateConstraints?.[props.fn]?.[
"entities"
]?.includes(`${record.entity}`)
? "GrayText"
: "inherit",
}}
>
{isSourcedFromPlanningData ? (
<Typography variant="body2">
<Typography variant="body2" component="span">
<Link
href={`https://www.planning.data.gov.uk/entity/${record.entity}`}
target="_blank"
sx={{
color: props.inaccurateConstraints?.[props.fn]?.[
"entities"
]?.includes(`${record.entity}`)
? "GrayText"
: "inherit",
}}
>
{formatEntityName(record, props.metadata)}
</Link>
</Typography>
) : (
<Typography variant="body2">{record.name}</Typography>
)}
{props.inaccurateConstraints?.[props.fn]?.[
"entities"
]?.includes(`${record.entity}`) && (
<Typography variant="body2" component="span">
{` [Not applicable]`}
</Typography>
)}
</ListItem>
))}
</List>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Grid from "@mui/material/Grid";
import Typography from "@mui/material/Typography";
import visuallyHidden from "@mui/utils/visuallyHidden";
import { Constraint, Metadata } from "@opensystemslab/planx-core/types";
import omit from "lodash/omit";
import React, { useState } from "react";
import InputLabel from "ui/public/InputLabel";
import ChecklistItem from "ui/shared/ChecklistItem";
Expand Down Expand Up @@ -60,9 +61,14 @@ export const OverrideEntitiesModal = ({
if (reason && reason == "backdropClick") {
return;
}
// Clear any non-submitted inputs

// Clear any non-submitted inputs on cancel & sync parent state
setCheckedOptions(undefined);
setTextInput(undefined);
const newInaccurateConstraints = omit(inaccurateConstraints, fn);
setInaccurateConstraints(newInaccurateConstraints);

// Close modal
setShowModal(false);
};

Expand Down Expand Up @@ -103,7 +109,7 @@ export const OverrideEntitiesModal = ({
} else if (invalidInput) {
setShowInputError(true);
} else {
// Update inaccurateConstraints in parent component state on valid Modal submit
// Update inaccurateConstraints in parent component state on valid submit
const newInaccurateConstraints = {
...inaccurateConstraints,
...{ [fn]: { entities: checkedOptions, reason: textInput } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ interface InaccurateConstraint {
}

export type InaccurateConstraints =
| Record<Constraint["fn"], InaccurateConstraint>
| Record<string, InaccurateConstraint>
| undefined;

export default Component;
Expand Down

0 comments on commit dc5a7e9

Please sign in to comment.