Skip to content

Commit

Permalink
chore: account for title boundaries in document templates (#2696)
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak authored Jan 24, 2024
1 parent 185e2a0 commit ecf5970
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 45 deletions.
9 changes: 9 additions & 0 deletions api.planx.uk/modules/admin/session/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { generateApplicationHTML } from "@opensystemslab/planx-core";
import { $api } from "../../../client";
import type { RequestHandler } from "express";
import type { PlanXExportData } from "@opensystemslab/planx-core/types";
import { DrawBoundaryUserAction } from "@opensystemslab/planx-core/dist/templates/html/map/Map";

type HTMLExportHandler = RequestHandler<{ sessionId: string }, string>;

Expand All @@ -27,10 +28,14 @@ export const getHTMLExport: HTMLExportHandler = async (req, res, next) => {
const boundingBox = session.data.passport.data[
"property.boundary.site.buffered"
] as unknown as GeoJSON.Feature;
const userAction = session.data.passport.data?.[
"drawBoundary.action"
] as unknown as DrawBoundaryUserAction | undefined;

const html = generateApplicationHTML({
planXExportData: responses as PlanXExportData[],
boundingBox,
userAction,
});

res.header("Content-type", "text/html");
Expand Down Expand Up @@ -70,10 +75,14 @@ export const getRedactedHTMLExport: HTMLExportHandler = async (
const boundingBox = session.data.passport.data[
"property.boundary.site.buffered"
] as unknown as GeoJSON.Feature;
const userAction = session.data.passport.data?.[
"drawBoundary.action"
] as unknown as DrawBoundaryUserAction | undefined;

const html = generateApplicationHTML({
planXExportData: redactedResponses as PlanXExportData[],
boundingBox,
userAction,
});

res.header("Content-type", "text/html");
Expand Down
5 changes: 5 additions & 0 deletions api.planx.uk/modules/send/utils/exportZip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@ export async function buildSubmissionExportZip({
}

const boundingBox = passport.data["property.boundary.site.buffered"];
const userAction = passport.data?.["drawBoundary.action"];
// generate and add an HTML overview document for the submission to zip
const overviewHTML = generateApplicationHTML({
planXExportData: responses as PlanXExportData[],
boundingBox,
userAction,
});
await zip.addFile({
name: "Overview.htm",
Expand All @@ -124,6 +126,7 @@ export async function buildSubmissionExportZip({
const redactedOverviewHTML = generateApplicationHTML({
planXExportData: redactedResponses as PlanXExportData[],
boundingBox,
userAction,
});
await zip.addFile({
name: "RedactedOverview.htm",
Expand All @@ -133,6 +136,7 @@ export async function buildSubmissionExportZip({
// add an optional GeoJSON file to zip
const geojson = passport?.data?.["property.boundary.site"];
if (geojson) {
if (userAction) geojson["properties"]["planx_user_action"] = userAction;
const geoBuff = Buffer.from(JSON.stringify(geojson, null, 2));
zip.addFile({
name: "LocationPlanGeoJSON.geojson",
Expand All @@ -143,6 +147,7 @@ export async function buildSubmissionExportZip({
const boundaryHTML = generateMapHTML({
geojson,
boundingBox,
userAction,
});
await zip.addFile({
name: "LocationPlan.htm",
Expand Down
2 changes: 1 addition & 1 deletion api.planx.uk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"dependencies": {
"@airbrake/node": "^2.1.8",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#4b625d9",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#9bf211f",
"@types/isomorphic-fetch": "^0.0.36",
"adm-zip": "^0.5.10",
"aws-sdk": "^2.1467.0",
Expand Down
23 changes: 15 additions & 8 deletions api.planx.uk/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e/tests/api-driven/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"dependencies": {
"@cucumber/cucumber": "^9.3.0",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#4b625d9",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#9bf211f",
"axios": "^1.6.0",
"dotenv": "^16.3.1",
"dotenv-expand": "^10.0.0",
Expand Down
26 changes: 13 additions & 13 deletions e2e/tests/api-driven/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e/tests/ui-driven/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"postinstall": "./install-dependencies.sh"
},
"dependencies": {
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#4b625d9",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#9bf211f",
"axios": "^1.6.2",
"dotenv": "^16.3.1",
"eslint": "^8.56.0",
Expand Down
26 changes: 13 additions & 13 deletions e2e/tests/ui-driven/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion editor.planx.uk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@mui/styles": "^5.15.2",
"@mui/utils": "^5.15.2",
"@opensystemslab/map": "^0.7.9",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#4b625d9",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#9bf211f",
"@tiptap/core": "^2.0.3",
"@tiptap/extension-bold": "^2.0.3",
"@tiptap/extension-bubble-menu": "^2.1.13",
Expand Down
10 changes: 5 additions & 5 deletions editor.planx.uk/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default function PlotNewAddress(props: PlotNewAddressProps): FCReturn {
drawType="Point"
geojsonData={JSON.stringify(props?.boundary)}
geojsonColor="#efefef"
geojsonBuffer="10"
geojsonBuffer={10}
resetControlImage="trash"
showScale
showNorthArrow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ function DrawBoundary(props: ComponentProps) {
geojsonData={JSON.stringify(geodata)}
geojsonColor="#ff0000"
geojsonFill
geojsonBuffer="20"
geojsonBuffer={20}
osProxyEndpoint={`${process.env.REACT_APP_API_URL}/proxy/ordnance-survey`}
hideResetControl
staticMode
Expand Down

0 comments on commit ecf5970

Please sign in to comment.