From e873e11022cfb73822d30fa155cdb9a01dc226d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Fri, 28 Jun 2024 11:27:14 +0100 Subject: [PATCH] feat: Remove 'unique' property from List schema (`QuestionField`) (#3331) --- .../src/@planx/components/List/Public/Fields.tsx | 13 ------------- .../@planx/components/List/Public/index.test.tsx | 1 - editor.planx.uk/src/@planx/components/List/model.ts | 1 - 3 files changed, 15 deletions(-) diff --git a/editor.planx.uk/src/@planx/components/List/Public/Fields.tsx b/editor.planx.uk/src/@planx/components/List/Public/Fields.tsx index 6c99ce5613..eeb79a1d84 100644 --- a/editor.planx.uk/src/@planx/components/List/Public/Fields.tsx +++ b/editor.planx.uk/src/@planx/components/List/Public/Fields.tsx @@ -152,18 +152,6 @@ export const SelectFieldInput: React.FC> = (props) => { const { formik, activeIndex } = useListContext(); const { id, data } = props; - const isDisabled = (option: Option) => { - if (!props.unique) return false; - - const existingValues = formik.values.userData - .map((response) => response[data.fn]) - .filter( - (value) => value === option.data.val || value === option.data.text, - ); - - return existingValues.includes(option.data.val || option.data.text); - }; - return ( > = (props) => { {option.data.text} diff --git a/editor.planx.uk/src/@planx/components/List/Public/index.test.tsx b/editor.planx.uk/src/@planx/components/List/Public/index.test.tsx index f112e3d39a..a769a82c3f 100644 --- a/editor.planx.uk/src/@planx/components/List/Public/index.test.tsx +++ b/editor.planx.uk/src/@planx/components/List/Public/index.test.tsx @@ -383,7 +383,6 @@ describe("Form validation and error handling", () => { test.todo("text fields use existing validation schemas"); test.todo("number fields use existing validation schemas"); test.todo("question fields use validation schema"); - test.todo("unique constraints are enforced on question where this is set"); test.todo("an error displays if the minimum number of items is not met"); test.todo("an error displays if the maximum number of items is exceeded"); test.todo( diff --git a/editor.planx.uk/src/@planx/components/List/model.ts b/editor.planx.uk/src/@planx/components/List/model.ts index e4d887ff0a..65adc60975 100644 --- a/editor.planx.uk/src/@planx/components/List/model.ts +++ b/editor.planx.uk/src/@planx/components/List/model.ts @@ -40,7 +40,6 @@ export type NumberField = { export type QuestionField = { type: "question"; - unique?: boolean; data: QuestionInput & { fn: string }; };