Skip to content

Commit

Permalink
passport values too
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak committed Dec 17, 2024
1 parent 562f460 commit 6e6e1d3
Show file tree
Hide file tree
Showing 22 changed files with 52 additions and 52 deletions.
4 changes: 2 additions & 2 deletions api.planx.uk/modules/admin/session/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const getHTMLExport: HTMLExportHandler = async (req, res, next) => {

const responses = await $api.export.csvData(req.params.sessionId);
const boundingBox = session.data.passport.data[
"property.boundary.site.buffered"
"proposal.site.buffered"
] as unknown as GeoJSON.Feature;
const userAction = session.data.passport.data?.[
"drawBoundary.action"
Expand Down Expand Up @@ -75,7 +75,7 @@ export const getRedactedHTMLExport: HTMLExportHandler = async (
req.params.sessionId,
);
const boundingBox = session.data.passport.data[
"property.boundary.site.buffered"
"proposal.site.buffered"
] as unknown as GeoJSON.Feature;
const userAction = session.data.passport.data?.[
"drawBoundary.action"
Expand Down
4 changes: 2 additions & 2 deletions api.planx.uk/modules/send/utils/exportZip.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe("buildSubmissionExportZip", () => {
});

test("geojson and location plan is excluded when not present", async () => {
// set-up mock session passport excluding "property.boundary.site"
// set-up mock session passport excluding "proposal.site"
const lowcalSessionWithoutBoundary: Partial<LowCalSession> = {
...mockLowcalSession,
id: "1234",
Expand All @@ -146,7 +146,7 @@ describe("buildSubmissionExportZip", () => {
passport: {
data: {
...mockLowcalSession.data!.passport.data,
"property.boundary.site": undefined,
"proposal.site": undefined,
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions api.planx.uk/modules/send/utils/exportZip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export async function buildSubmissionExportZip({
}
}

const boundingBox = passport.data["property.boundary.site.buffered"];
const boundingBox = passport.data["proposal.site.buffered"];
const userAction = passport.data?.["drawBoundary.action"];

// generate and add an HTML overview document for the submission to zip
Expand All @@ -173,7 +173,7 @@ export async function buildSubmissionExportZip({

// add an optional GeoJSON file to zip
const geojson: GeoJSON.Feature | undefined =
passport?.data?.["property.boundary.site"];
passport?.data?.["proposal.site"];
if (geojson) {
if (userAction) {
geojson["properties"] ??= {};
Expand Down
2 changes: 1 addition & 1 deletion api.planx.uk/tests/mocks/saveAndReturnMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const mockLowcalSession: LowCalSession = {
},
"drawBoundary.action": "Amended the title boundary",
"proposal.projectType": ["new.office"],
"property.boundary.site": {
"proposal.site": {
type: "Feature",
geometry: {
type: "Polygon",
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/api-driven/src/invite-to-pay/mocks/flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -157049,7 +157049,7 @@
"description": "<p>The red line shown below should include:</p><ul><li><p>the outline of your property boundary</p></li><li><p>any works outside the property boundary</p></li><li><p>areas that will be closed off or you&apos;ll need access to during the works</p></li></ul><p>If the red line already includes all these, select continue. If not, select More information for guidance on how to amend or redraw the outline.</p>",
"howMeasured": "<p>We have pre-populated the map with a red outline that includes the entire property using information from the Land Registry.</p><p>In some cases, this outline might not include all the works or the areas that will be closed off. This might be because you&apos;re proposing works to a public highway (such as a dropped kerb), doing works that involve multiple properties, or works to a building that is part of a larger estate.</p><p>In these cases, you should amend the red outline by dragging the edges, or erase it by clicking the 🗑-icon on the map and draw a new outline.</p><p></p><h1>How to draw and amend the outline</h1><ol><li><p>Move the cursor to the corner you want to start with and click or tap once.</p></li><li><p>Move the cursor to the next corner and click or tap.</p></li><li><p>Repeat until you have the shape you need.</p></li><li><p>Click or tap the last corner again to stop drawing.</p></li><li><p>To amend the outline, click or tap on a line and drag it into a new position.</p></li></ol><img src=\"https://api.editor.planx.uk/file/public/dni98ojg/Draw_Outline_2.gif\">",
"hideFileUpload": false,
"fn": "property.boundary.site",
"fn": "proposal.site",
"titleForUploading": "Upload a location plan",
"descriptionForUploading": "<p>Your location plan must:</p><ul><li><p>be based on an accurate, recognisable map</p></li><li><p>be drawn to a scale, labelled, and/or marked with a scale bar</p></li><li><p>show the site outline in red</p></li><li><p>include a<strong> </strong>north point</p></li></ul>"
},
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/api-driven/src/invite-to-pay/mocks/session.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"uniform.consentRegime": ["Certificate of Lawfulness"],
"application.about.form": ["Proposed building works"],
"property.EPCKnown.form": ["No"],
"property.boundary.site": {
"proposal.site": {
"type": "Feature",
"geometry": {
"type": "Polygon",
Expand Down Expand Up @@ -814,7 +814,7 @@
"auto": false,
"data": {
"proposal.siteArea": 21.6,
"property.boundary.site": {
"proposal.site": {
"type": "Feature",
"geometry": {
"type": "Polygon",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ test("recovers previously submitted files when clicking the back button", async

const { user } = setup(
<DrawBoundary
fn="property.boundary.site"
fn="proposal.site"
description=""
descriptionForUploading=""
title="Draw a boundary"
Expand All @@ -64,7 +64,7 @@ test("recovers previously submitted files when clicking the back button", async
test("recovers previously submitted drawing when clicking the back button", async () => {
const handleSubmit = vi.fn();
const previouslySubmittedData = {
"property.boundary.site": {
"proposal.site": {
type: "Feature",
properties: {},
geometry: {
Expand All @@ -84,7 +84,7 @@ test("recovers previously submitted drawing when clicking the back button", asyn

const { user } = setup(
<DrawBoundary
fn="property.boundary.site"
fn="proposal.site"
description=""
descriptionForUploading=""
title="Draw a boundary"
Expand All @@ -106,7 +106,7 @@ test("recovers previously submitted drawing when clicking the back button", asyn
it("should not have any accessibility violations", async () => {
const { container } = setup(
<DrawBoundary
fn="property.boundary.site"
fn="proposal.site"
description="description1"
descriptionForUploading="description1"
title="Draw a boundary"
Expand All @@ -122,7 +122,7 @@ test("shows the file upload option by default and requires user data to continue

const { user } = setup(
<DrawBoundary
fn="property.boundary.site"
fn="proposal.site"
description=""
descriptionForUploading=""
title="Draw a boundary"
Expand Down Expand Up @@ -157,7 +157,7 @@ test("hides the upload option and allows user to continue without drawing if edi

const { user } = setup(
<DrawBoundary
fn="property.boundary.site"
fn="proposal.site"
description=""
descriptionForUploading=""
title="Draw a boundary"
Expand Down Expand Up @@ -192,7 +192,7 @@ test("captures output data in the correct format when uploading a file", async (

const { user } = setup(
<DrawBoundary
fn="property.boundary.site"
fn="proposal.site"
description=""
descriptionForUploading=""
title="Draw a boundary"
Expand Down Expand Up @@ -328,7 +328,7 @@ test("appends to existing '_requestedFiles' value", async () => {
titleForUploading: "Upload a location plan",
descriptionForUploading: "",
hideFileUpload: false,
fn: "property.boundary.site",
fn: "proposal.site",
},
},
};
Expand All @@ -337,7 +337,7 @@ test("appends to existing '_requestedFiles' value", async () => {

const { user } = setup(
<DrawBoundary
fn="property.boundary.site"
fn="proposal.site"
description=""
descriptionForUploading=""
title="Draw a boundary"
Expand Down Expand Up @@ -399,7 +399,7 @@ test("submits data based on the page you continue onwards from", async () => {

// Previously submitted data is a good proxy for having previously fetched a title boundary and arriving to Draw with geojson in passport !
const previouslySubmittedData = {
"property.boundary.site": {
"proposal.site": {
type: "Feature",
properties: {},
geometry: {
Expand All @@ -419,7 +419,7 @@ test("submits data based on the page you continue onwards from", async () => {

const { user } = setup(
<DrawBoundary
fn="property.boundary.site"
fn="proposal.site"
description=""
descriptionForUploading=""
title="Draw a boundary"
Expand Down Expand Up @@ -449,8 +449,8 @@ test("submits data based on the page you continue onwards from", async () => {
// Confirm that file is NOT saved to passport, but geojson is
const submitted = handleSubmit.mock.calls[0][0];
expect(submitted.data).not.toHaveProperty(PASSPORT_UPLOAD_KEY);
expect(submitted.data["property.boundary.site"]).toEqual(
previouslySubmittedData["property.boundary.site"],
expect(submitted.data["proposal.site"]).toEqual(
previouslySubmittedData["proposal.site"],
);

// DrawBoundary action captured correctly based on page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ export default function Component(props: Props) {

const previousBoundary =
props.previouslySubmittedData?.data?.[props.fn] ||
passport.data?.["property.boundary.title"];
passport.data?.["property.boundary"];
const previousArea =
props.previouslySubmittedData?.data?.[props.fn] ||
passport.data?.["property.boundary.title.area"];
passport.data?.["proposal.site.area"];
const [boundary, setBoundary] = useState<Boundary>(previousBoundary);
const [area, setArea] = useState<number | undefined>(previousArea);
const [mapValidationError, setMapValidationError] = useState<string>();
Expand Down Expand Up @@ -167,7 +167,7 @@ export default function Component(props: Props) {
// Track the type of map interaction
if (
boundary?.geometry ===
passport.data?.["property.boundary.title"]?.geometry
passport.data?.["property.boundary"]?.geometry
) {
newPassportData[PASSPORT_COMPONENT_ACTION_KEY] =
DrawBoundaryUserAction.Accept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const defaultContent: DrawBoundary = {
howMeasured:
'<p>We have pre-populated the map with a red outline that includes the entire property using information from Land Registry.</p><p>In some cases, this outline might not include all the works or the areas that will be closed off. This might be because you&apos;re proposing works to a public highway (such as a dropped kerb), doing works that involve multiple properties, or works to a building that is part of a larger estate.</p><p>In these cases, you should amend the red outline by dragging the edges, or erase it by clicking the :wastebasket:-icon on the map and draw a new outline.</p><p></p><h1>How to draw and amend the outline</h1><ol><li><p>Move the cursor to the corner you want to start with and click or tap once.</p></li><li><p>Move the cursor to the next corner and click or tap.</p></li><li><p>Repeat until you have the shape you need.</p></li><li><p>Click or tap the last corner again to stop drawing.</p></li><li><p>To amend the outline, click or tap on a line and drag it into a new position.</p></li></ol><img src="https://api.editor.planx.uk/file/public/dni98ojg/Draw_Outline_2.gif">',
hideFileUpload: false,
fn: "property.boundary.site",
fn: "proposal.site",
titleForUploading: "Upload a location plan",
descriptionForUploading:
"<p>Your location plan must:</p><ul><li><p>be based on an accurate, recognisable map</p></li><li><p>be drawn to a scale, labelled, and/or marked with a scale bar</p></li><li><p>show the site outline in red</p></li><li><p>include a<strong> </strong>north point</p></li></ul>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ const osAddressProps = {
"property.type": ["residential.HMO.parent"],
"property.localAuthorityDistrict": ["Southwark"],
"property.region": ["London"],
"property.boundary.title.area": 1232.22,
"property.boundary.title.area.hectares": 0.123222,
"property.boundary.title": {
"property.boundary.area": 1232.22,
"property.boundary.area.hectares": 0.123222,
"property.boundary": {
geometry: {
type: "MultiPolygon",
coordinates: [
Expand Down Expand Up @@ -85,9 +85,9 @@ const proposedAddressProps = {
},
"property.localAuthorityDistrict": ["Southwark"],
"property.region": ["London"],
"property.boundary.title.area": 1232.22,
"property.boundary.title.area.hectares": 0.123222,
"property.boundary.title": {
"proposal.site.area": 1232.22,
"proposal.site.area.hectares": 0.123222,
"property.boundary": {
geometry: {
type: "MultiPolygon",
coordinates: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ function Component(props: Props) {
if (titleBoundary) {
const areaSquareMetres =
Math.round(area(titleBoundary as Feature) * 100) / 100;
newPassportData["property.boundary.title"] = titleBoundary;
newPassportData["property.boundary.title.area"] = areaSquareMetres;
newPassportData["property.boundary.title.area.hectares"] =
newPassportData["property.boundary"] = titleBoundary;
newPassportData["property.boundary.area"] = areaSquareMetres;
newPassportData["property.boundary.area.hectares"] =
squareMetresToHectares(areaSquareMetres);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ const Root = () => {
basemap={basemap}
ariaLabelOlFixedOverlay={`An interactive map for plotting and describing individual ${schemaName.toLocaleLowerCase()}`}
geojsonData={
passport && JSON.stringify(passport["property.boundary.site"])
passport && JSON.stringify(passport["proposal.site"])
}
geojsonBuffer={30}
drawMode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function Component(props: Props) {
state.cachedBreadcrumbs,
state.teamSlug,
state.teamIntegrations?.hasPlanningData,
state.computePassport().data?.["property.boundary.site"],
state.computePassport().data?.["proposal.site"],
state.computePassport().data?.["_overrides"],
(state.computePassport().data?.["_address"] as SiteAddress) || {},
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const simpleBreadcrumbs: Store.Breadcrumbs = {
"property.type": ["commercial.office.workspace.gov.local"],
"property.localAuthorityDistrict": ["Birmingham"],
"property.region": ["West Midlands"],
"property.boundary.title": {
"property.boundary": {
geometry: {
type: "MultiPolygon",
coordinates: [
Expand All @@ -88,8 +88,8 @@ export const simpleBreadcrumbs: Store.Breadcrumbs = {
"organisation-entity": "13",
},
},
"property.boundary.title.area": 8242.37,
"property.boundary.title.area.hectares": 0.8242370000000001,
"proposal.site.area": 8242.37,
"proposal.site.area.hectares": 0.8242370000000001,
"findProperty.action": "Selected an existing address",
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function Component(props: PublicProps<PropertyInformation>) {
localAuthorityDistrict={
passport.data?.["property.localAuthorityDistrict"]
}
titleBoundary={passport.data?.["property.boundary.title"]}
titleBoundary={passport.data?.["property.boundary"]}
blpuCodes={blpuCodes}
overrideAnswer={overrideAnswer}
handleSubmit={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export const drawBoundaryFlow = {
data: {
title: "Draw the boundary of the property",
hideFileUpload: false,
fn: "property.boundary.site",
fn: "proposal.site",
titleForUploading: "Upload a location plan",
},
type: 10,
Expand Down
2 changes: 1 addition & 1 deletion editor.planx.uk/src/@planx/components/SetValue/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const handleSetValue: HandleSetValue = ({
}) => {
// We do not amend values set at objects
// These are internal exceptions we do not want to allow users to edit
// e.g. property.boundary.title
// e.g. property.boundary
const isObject =
typeof previousValues === "object" &&
!Array.isArray(previousValues) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const MapFieldInput: React.FC<Props<MapField>> = (props) => {
height={400}
basemap={mapOptions?.basemap}
geojsonData={JSON.stringify(
passport.data?.["property.boundary.site"],
passport.data?.["proposal.site"],
)}
geojsonBuffer={30}
drawMode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export const mockFlow: FlowGraph = {
title: ".",
description: "<p>.</p>",
hideFileUpload: false,
fn: "property.boundary.site",
fn: "proposal.site",
titleForUploading: "Elephant",
descriptionForUploading: "<p>Panda</p>",
},
Expand Down Expand Up @@ -610,7 +610,7 @@ export const mockDrawBoundaryResult: SearchResult<IndexedNode> = {
title: ".",
description: "<p>.</p>",
hideFileUpload: false,
fn: "property.boundary.site",
fn: "proposal.site",
titleForUploading: "Elephant",
descriptionForUploading: "<p>Panda</p>",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"drawBoundary": {
"auto": false,
"data": {
"property.boundary.site": {
"proposal.site": {
"type": "Feature",
"geometry": {
"type": "Polygon",
Expand All @@ -48,7 +48,7 @@
},
"properties": null
},
"property.boundary.area": 109.43
"proposal.site.area": 109.43
}
},
"planningConstraints": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"drawBoundary": {
"data": {
"fn": "property.boundary.site"
"fn": "proposal.site"
},
"type": 10
},
Expand Down
Loading

0 comments on commit 6e6e1d3

Please sign in to comment.