From 562f460ea0274d69e1d7c0d6032a7ce8056fba0b Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Tue, 17 Dec 2024 14:55:05 +0100 Subject: [PATCH] dataFieldBoundary to fn, remove dataFieldArea prop --- .../modules/flows/downloadSchema/service.ts | 5 +--- .../src/invite-to-pay/mocks/flow.json | 3 +-- .../@planx/components/DrawBoundary/Editor.tsx | 20 +++----------- .../DrawBoundary/Public/Public.test.tsx | 27 +++++++------------ .../components/DrawBoundary/Public/index.tsx | 16 +++++------ .../@planx/components/DrawBoundary/model.ts | 10 +++---- .../Review/Public/mocks/fileUpload.tsx | 3 +-- .../components/shared/Preview/SummaryList.tsx | 2 +- .../getDisplayDetailsForResult.tsx | 6 ----- .../components/Sidebar/Search/facets.ts | 6 ----- .../Sidebar/Search/mocks/allFacetFlow.ts | 6 ++--- .../mocks/flowWithPassportComponents.json | 2 +- 12 files changed, 31 insertions(+), 75 deletions(-) diff --git a/api.planx.uk/modules/flows/downloadSchema/service.ts b/api.planx.uk/modules/flows/downloadSchema/service.ts index de83ba112a..47d48b92bd 100644 --- a/api.planx.uk/modules/flows/downloadSchema/service.ts +++ b/api.planx.uk/modules/flows/downloadSchema/service.ts @@ -17,10 +17,7 @@ export const getFlowSchema = async (flowId: string) => { type: nodeData?.type?.toString() || "_root", text: nodeData.data?.text, planx_variable: - nodeData.data?.fn || - nodeData.data?.val || - nodeData.data?.output || - nodeData.data?.dataFieldBoundary, + nodeData.data?.fn || nodeData.data?.val || nodeData.data?.output, }), ); diff --git a/e2e/tests/api-driven/src/invite-to-pay/mocks/flow.json b/e2e/tests/api-driven/src/invite-to-pay/mocks/flow.json index 6ad9eb5a31..e07cd72fdd 100644 --- a/e2e/tests/api-driven/src/invite-to-pay/mocks/flow.json +++ b/e2e/tests/api-driven/src/invite-to-pay/mocks/flow.json @@ -157048,9 +157048,8 @@ "policyRef": "

The Town and Country Planning (Development Management Procedure) (England) Order 2015,

Planning Practice Guidance (PPG)

", "description": "

The red line shown below should include:

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.

", "howMeasured": "

We have pre-populated the map with a red outline that includes the entire property using information from the Land Registry.

In some cases, this outline might not include all the works or the areas that will be closed off. This might be because you'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.

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.

How to draw and amend the outline

  1. Move the cursor to the corner you want to start with and click or tap once.

  2. Move the cursor to the next corner and click or tap.

  3. Repeat until you have the shape you need.

  4. Click or tap the last corner again to stop drawing.

  5. To amend the outline, click or tap on a line and drag it into a new position.

", - "dataFieldArea": "property.boundary.area", "hideFileUpload": false, - "dataFieldBoundary": "property.boundary.site", + "fn": "property.boundary.site", "titleForUploading": "Upload a location plan", "descriptionForUploading": "

Your location plan must:

" }, diff --git a/editor.planx.uk/src/@planx/components/DrawBoundary/Editor.tsx b/editor.planx.uk/src/@planx/components/DrawBoundary/Editor.tsx index c8b11161ab..44b6599ff1 100644 --- a/editor.planx.uk/src/@planx/components/DrawBoundary/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/DrawBoundary/Editor.tsx @@ -53,25 +53,13 @@ function DrawBoundaryComponent(props: Props) { onChange={formik.handleChange} /> - + - - - - - diff --git a/editor.planx.uk/src/@planx/components/DrawBoundary/Public/Public.test.tsx b/editor.planx.uk/src/@planx/components/DrawBoundary/Public/Public.test.tsx index 208926e51a..255b2085a2 100644 --- a/editor.planx.uk/src/@planx/components/DrawBoundary/Public/Public.test.tsx +++ b/editor.planx.uk/src/@planx/components/DrawBoundary/Public/Public.test.tsx @@ -42,8 +42,7 @@ test("recovers previously submitted files when clicking the back button", async const { user } = setup( { const { container } = setup( { titleForUploading: "Upload a location plan", descriptionForUploading: "", hideFileUpload: false, - dataFieldBoundary: "property.boundary.site", - dataFieldArea: "property.boundary.area", + fn: "property.boundary.site", }, }, }; @@ -344,8 +337,7 @@ test("appends to existing '_requestedFiles' value", async () => { const { user } = setup( { const { user } = setup( state.computePassport()); const previousBoundary = - props.previouslySubmittedData?.data?.[props.dataFieldBoundary] || + props.previouslySubmittedData?.data?.[props.fn] || passport.data?.["property.boundary.title"]; const previousArea = - props.previouslySubmittedData?.data?.[props.dataFieldArea] || + props.previouslySubmittedData?.data?.[props.fn] || passport.data?.["property.boundary.title.area"]; const [boundary, setBoundary] = useState(previousBoundary); const [area, setArea] = useState(previousArea); @@ -150,17 +150,17 @@ export default function Component(props: Props) { props.handleSubmit?.({ data: { ...newPassportData } }); } - if (boundary && props.dataFieldBoundary) { - newPassportData[props.dataFieldBoundary] = boundary; - newPassportData[`${props.dataFieldBoundary}.buffered`] = buffer( + if (boundary && props.fn) { + newPassportData[props.fn] = boundary; + newPassportData[`${props.fn}.buffered`] = buffer( boundary, bufferInMeters, { units: "meters" }, ); - if (area && props.dataFieldArea) { - newPassportData[props.dataFieldArea] = area; - newPassportData[`${props.dataFieldArea}.hectares`] = + if (area && props.fn) { + newPassportData[`${props.fn}.area`] = area; + newPassportData[`${props.fn}.hectares`] = squareMetresToHectares(area); } diff --git a/editor.planx.uk/src/@planx/components/DrawBoundary/model.ts b/editor.planx.uk/src/@planx/components/DrawBoundary/model.ts index 14e7098779..f2993c1f5b 100644 --- a/editor.planx.uk/src/@planx/components/DrawBoundary/model.ts +++ b/editor.planx.uk/src/@planx/components/DrawBoundary/model.ts @@ -13,8 +13,7 @@ export interface DrawBoundary extends BaseNodeData { titleForUploading: string; descriptionForUploading: string; hideFileUpload?: boolean; - dataFieldBoundary: string; - dataFieldArea: string; + fn: string; } export const parseDrawBoundary = ( @@ -29,9 +28,7 @@ export const parseDrawBoundary = ( data?.descriptionForUploading || defaultContent?.["descriptionForUploading"], hideFileUpload: data?.hideFileUpload || defaultContent?.["hideFileUpload"], - dataFieldBoundary: - data?.dataFieldBoundary || defaultContent?.["dataFieldBoundary"], - dataFieldArea: data?.dataFieldArea || defaultContent?.["dataFieldArea"], + fn: data?.fn || defaultContent?.["fn"], info: data?.info || defaultContent?.["info"], policyRef: data?.policyRef || defaultContent?.["policyRef"], howMeasured: data?.howMeasured || defaultContent?.["howMeasured"], @@ -54,8 +51,7 @@ const defaultContent: DrawBoundary = { howMeasured: '

We have pre-populated the map with a red outline that includes the entire property using information from Land Registry.

In some cases, this outline might not include all the works or the areas that will be closed off. This might be because you'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.

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.

How to draw and amend the outline

  1. Move the cursor to the corner you want to start with and click or tap once.

  2. Move the cursor to the next corner and click or tap.

  3. Repeat until you have the shape you need.

  4. Click or tap the last corner again to stop drawing.

  5. To amend the outline, click or tap on a line and drag it into a new position.

', hideFileUpload: false, - dataFieldBoundary: "property.boundary.site", - dataFieldArea: "property.boundary.area", + fn: "property.boundary.site", titleForUploading: "Upload a location plan", descriptionForUploading: "

Your location plan must:

  • be based on an accurate, recognisable map

  • be drawn to a scale, labelled, and/or marked with a scale bar

  • show the site outline in red

  • include a north point

", diff --git a/editor.planx.uk/src/@planx/components/Review/Public/mocks/fileUpload.tsx b/editor.planx.uk/src/@planx/components/Review/Public/mocks/fileUpload.tsx index cbbbbd9e15..3b5c60decf 100644 --- a/editor.planx.uk/src/@planx/components/Review/Public/mocks/fileUpload.tsx +++ b/editor.planx.uk/src/@planx/components/Review/Public/mocks/fileUpload.tsx @@ -156,9 +156,8 @@ export const drawBoundaryFlow = { EO6DzPso8o: { data: { title: "Draw the boundary of the property", - dataFieldArea: "property.boundary.area", hideFileUpload: false, - dataFieldBoundary: "property.boundary.site", + fn: "property.boundary.site", titleForUploading: "Upload a location plan", }, type: 10, diff --git a/editor.planx.uk/src/@planx/components/shared/Preview/SummaryList.tsx b/editor.planx.uk/src/@planx/components/shared/Preview/SummaryList.tsx index 80d2692bc6..29feafb0ca 100644 --- a/editor.planx.uk/src/@planx/components/shared/Preview/SummaryList.tsx +++ b/editor.planx.uk/src/@planx/components/shared/Preview/SummaryList.tsx @@ -480,7 +480,7 @@ function DateInput(props: ComponentProps) { function DrawBoundary(props: ComponentProps) { // check if the user drew a boundary, uploaded a file, or both (or neither if props.node.data?.hideFileUpload is triggered "on") - const geodata = props.userData?.data?.[props.node.data?.dataFieldBoundary]; + const geodata = props.userData?.data?.[props.node.data?.fn]; const locationPlan = props.userData?.data?.[PASSPORT_UPLOAD_KEY]; const fileName = locationPlan ? locationPlan[0].url.split("/").pop() : ""; diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Sidebar/Search/SearchResultCard/getDisplayDetailsForResult.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Sidebar/Search/SearchResultCard/getDisplayDetailsForResult.tsx index c725d96214..806a193fc6 100644 --- a/editor.planx.uk/src/pages/FlowEditor/components/Sidebar/Search/SearchResultCard/getDisplayDetailsForResult.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/components/Sidebar/Search/SearchResultCard/getDisplayDetailsForResult.tsx @@ -44,12 +44,6 @@ const keyFormatters: KeyMap = { "data.fileTypes.fn": { getDisplayKey: () => "File type (data)", }, - "data.dataFieldBoundary": { - getDisplayKey: () => "Boundary", - }, - "data.dataFieldArea": { - getDisplayKey: () => "Area", - }, "data.description": { getDisplayKey: ({ item }) => item.type === ComponentType.Answer diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Sidebar/Search/facets.ts b/editor.planx.uk/src/pages/FlowEditor/components/Sidebar/Search/facets.ts index a85b4329db..58d684601e 100644 --- a/editor.planx.uk/src/pages/FlowEditor/components/Sidebar/Search/facets.ts +++ b/editor.planx.uk/src/pages/FlowEditor/components/Sidebar/Search/facets.ts @@ -21,18 +21,12 @@ const listData: SearchFacets = [ "data.schema.fields.data.options.data.val", ]; -const drawBoundaryData: SearchFacets = [ - "data.dataFieldBoundary", - "data.dataFieldArea", -]; - /** Data fields used across PlanX components */ export const DATA_FACETS: SearchFacets = [ ...generalData, ...fileUploadAndLabelData, ...calculateData, ...listData, - ...drawBoundaryData, ]; const stripHTMLTags = (html = "") => diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Sidebar/Search/mocks/allFacetFlow.ts b/editor.planx.uk/src/pages/FlowEditor/components/Sidebar/Search/mocks/allFacetFlow.ts index 9d3e91b43d..fef56d7035 100644 --- a/editor.planx.uk/src/pages/FlowEditor/components/Sidebar/Search/mocks/allFacetFlow.ts +++ b/editor.planx.uk/src/pages/FlowEditor/components/Sidebar/Search/mocks/allFacetFlow.ts @@ -170,9 +170,8 @@ export const mockFlow: FlowGraph = { data: { title: ".", description: "

.

", - dataFieldArea: "property.boundary.area", hideFileUpload: false, - dataFieldBoundary: "property.boundary.site", + fn: "property.boundary.site", titleForUploading: "Elephant", descriptionForUploading: "

Panda

", }, @@ -610,9 +609,8 @@ export const mockDrawBoundaryResult: SearchResult = { data: { title: ".", description: "

.

", - dataFieldArea: "property.boundary.area", hideFileUpload: false, - dataFieldBoundary: "property.boundary.site", + fn: "property.boundary.site", titleForUploading: "Elephant", descriptionForUploading: "

Panda

", }, diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/mocks/flowWithPassportComponents.json b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/mocks/flowWithPassportComponents.json index f621b4065a..442fdc984b 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/mocks/flowWithPassportComponents.json +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/mocks/flowWithPassportComponents.json @@ -32,7 +32,7 @@ }, "drawBoundary": { "data": { - "dataFieldBoundary": "property.boundary.site" + "fn": "property.boundary.site" }, "type": 10 },