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

feat: Add Proposed Advertisements to List component and schema #3261

Closed
wants to merge 5 commits into from
Closed
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
2 changes: 2 additions & 0 deletions editor.planx.uk/src/@planx/components/List/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { ResidentialUnitsGLARemoved } from "./schemas/ResidentialUnits/GLA/Remov
import { ResidentialUnitsGLARetained } from "./schemas/ResidentialUnits/GLA/Retained";
import { ResidentialUnitsProposed } from "./schemas/ResidentialUnits/Proposed";
import { Zoo } from "./schemas/Zoo";
import { ProposedAdvertisements } from "./schemas/Adverts";

type Props = EditorProps<TYPES.List, List>;

Expand All @@ -40,6 +41,7 @@ export const SCHEMAS = [
schema: ResidentialUnitsGLARetained,
},
{ name: "Zoo (test)", schema: Zoo },
{ name: "Proposed advertisements", schema: ProposedAdvertisements },
];

function ListComponent(props: Props) {
Expand Down
40 changes: 40 additions & 0 deletions editor.planx.uk/src/@planx/components/List/schemas/Adverts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Schema } from "@planx/components/List/model";

export const ProposedAdvertisements: Schema = {
type: "Proposed advertisements",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this piece of text will be read into the title of each item & the "+ Add another ..." button - so it's actually best if it's singular rather than plural !

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I actually want only one fixed input without the ability to add additional list items, so I will try min: 1, max: 1.

fields: [
{
type: "number",
data: {
title: "How many fascia signs are you applying for?",
fn: "fascia",
allowNegatives: false,
},
},
{
type: "number",
data: {
title: "How many projecting or hanging signs are you applying for?",
fn: "projecting",
allowNegatives: false,
},
},
{
type: "number",
data: {
title: "How many hoardings are you applying for?",
fn: "hoarding",
allowNegatives: false,
},
},
{
type: "number",
data: {
title: "How many other advertisements are you applying for?",
fn: "other",
allowNegatives: false,
},
},
],
min: 0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: when min: 0, the component actually confusing loads like this - so we probably really want min: 1 ?

Screenshot from 2024-06-10 20-17-04

if we want it to be possible to "continue" without submitting any items, maybe there's a better way we can control that in the Editor modal using a simple toggle rather than in the schema via min ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I misunderstood what was being set by min and max. Looks like min: 0 isn't even possible, as it throws this when you try to add any item:
image

} as const;
Loading