diff --git a/api.planx.uk/package.json b/api.planx.uk/package.json index f16e2697d2..3a09be8110 100644 --- a/api.planx.uk/package.json +++ b/api.planx.uk/package.json @@ -13,7 +13,7 @@ "@airbrake/node": "^2.1.8", "@aws-sdk/client-s3": "^3.696.0", "@aws-sdk/s3-request-presigner": "^3.701.0", - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#574df5e", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#ae6e7f4", "@types/isomorphic-fetch": "^0.0.36", "adm-zip": "^0.5.10", "axios": "^1.7.4", diff --git a/api.planx.uk/pnpm-lock.yaml b/api.planx.uk/pnpm-lock.yaml index 94cea064b8..b834c86383 100644 --- a/api.planx.uk/pnpm-lock.yaml +++ b/api.planx.uk/pnpm-lock.yaml @@ -21,8 +21,8 @@ dependencies: specifier: ^3.701.0 version: 3.701.0 '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#574df5e - version: github.com/theopensystemslab/planx-core/574df5e + specifier: git+https://github.com/theopensystemslab/planx-core#ae6e7f4 + version: github.com/theopensystemslab/planx-core/ae6e7f4 '@types/isomorphic-fetch': specifier: ^0.0.36 version: 0.0.36 @@ -7312,8 +7312,8 @@ packages: resolution: {integrity: sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==} dev: false - github.com/theopensystemslab/planx-core/574df5e: - resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/574df5e} + github.com/theopensystemslab/planx-core/ae6e7f4: + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/ae6e7f4} name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true diff --git a/e2e/tests/api-driven/package.json b/e2e/tests/api-driven/package.json index 27ef5a4fb5..e9ab935b08 100644 --- a/e2e/tests/api-driven/package.json +++ b/e2e/tests/api-driven/package.json @@ -8,7 +8,7 @@ "packageManager": "pnpm@8.6.6", "dependencies": { "@cucumber/cucumber": "^11.1.1", - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#574df5e", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#ae6e7f4", "axios": "^1.7.4", "dotenv": "^16.3.1", "dotenv-expand": "^10.0.0", diff --git a/e2e/tests/api-driven/pnpm-lock.yaml b/e2e/tests/api-driven/pnpm-lock.yaml index 6dd53a997e..ba10cbeda0 100644 --- a/e2e/tests/api-driven/pnpm-lock.yaml +++ b/e2e/tests/api-driven/pnpm-lock.yaml @@ -9,8 +9,8 @@ dependencies: specifier: ^11.1.1 version: 11.1.1 '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#574df5e - version: github.com/theopensystemslab/planx-core/574df5e + specifier: git+https://github.com/theopensystemslab/planx-core#ae6e7f4 + version: github.com/theopensystemslab/planx-core/ae6e7f4 axios: specifier: ^1.7.4 version: 1.7.4 @@ -1137,7 +1137,7 @@ packages: dev: false /concat-map@0.0.1: - resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} + resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=} dev: false /convert-source-map@1.9.0: @@ -3052,8 +3052,8 @@ packages: resolution: {integrity: sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==} dev: false - github.com/theopensystemslab/planx-core/574df5e: - resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/574df5e} + github.com/theopensystemslab/planx-core/ae6e7f4: + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/ae6e7f4} name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true diff --git a/e2e/tests/ui-driven/package.json b/e2e/tests/ui-driven/package.json index 4b6a1da298..cea648c7ae 100644 --- a/e2e/tests/ui-driven/package.json +++ b/e2e/tests/ui-driven/package.json @@ -9,7 +9,7 @@ }, "type": "module", "dependencies": { - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#574df5e", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#ae6e7f4", "axios": "^1.7.4", "dotenv": "^16.3.1", "eslint": "^8.56.0", diff --git a/e2e/tests/ui-driven/pnpm-lock.yaml b/e2e/tests/ui-driven/pnpm-lock.yaml index a05fe5810e..098abde58a 100644 --- a/e2e/tests/ui-driven/pnpm-lock.yaml +++ b/e2e/tests/ui-driven/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: dependencies: '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#574df5e - version: github.com/theopensystemslab/planx-core/574df5e + specifier: git+https://github.com/theopensystemslab/planx-core#ae6e7f4 + version: github.com/theopensystemslab/planx-core/ae6e7f4 axios: specifier: ^1.7.4 version: 1.7.4 @@ -2601,8 +2601,8 @@ packages: resolution: {integrity: sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==} dev: false - github.com/theopensystemslab/planx-core/574df5e: - resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/574df5e} + github.com/theopensystemslab/planx-core/ae6e7f4: + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/ae6e7f4} name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true diff --git a/editor.planx.uk/src/@planx/components/Checklist/Editor/Editor.tsx b/editor.planx.uk/src/@planx/components/Checklist/Editor/Editor.tsx index a197a89170..07aec4b9a0 100644 --- a/editor.planx.uk/src/@planx/components/Checklist/Editor/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/Checklist/Editor/Editor.tsx @@ -1,4 +1,5 @@ import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; +import { DataFieldAutocomplete } from "@planx/components/shared/DataFieldAutocomplete"; import { FormikErrors, FormikValues, useFormik } from "formik"; import React, { useEffect, useRef } from "react"; import ImgInput from "ui/editor/ImgInput/ImgInput"; @@ -12,7 +13,6 @@ import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; import { Switch } from "ui/shared/Switch"; -import { DataFieldAutocomplete } from "@planx/components/shared/DataFieldAutocomplete"; import { Option, parseBaseNodeData } from "../../shared"; import { ICONS } from "../../shared/icons"; import type { Checklist } from "../model"; @@ -41,7 +41,7 @@ export const ChecklistEditor: React.FC = (props) => { : groupedOptions?.flatMap((group) => group.children); const filteredOptions = (sourceOptions || []).filter( - (option) => option.data.text + (option) => option.data.text, ); const processedOptions = filteredOptions.map((option) => ({ @@ -68,7 +68,7 @@ export const ChecklistEditor: React.FC = (props) => { }), }, }, - processedOptions + processedOptions, ); } else { alert(JSON.stringify({ type, ...values, options }, null, 2)); @@ -77,16 +77,16 @@ export const ChecklistEditor: React.FC = (props) => { validate: ({ options, groupedOptions, allRequired, ...values }) => { const errors: FormikErrors = {}; + // Account for flat or expandable Checklist options + options = options || groupedOptions?.flatMap((group) => group.children); + const exclusiveOptions: Option[] | undefined = options?.filter( - (option) => option.data.exclusive + (option) => option.data.exclusive, ); if (allRequired && exclusiveOptions && exclusiveOptions.length > 0) { errors.allRequired = 'Cannot configure exclusive "or" option alongside "all required" setting'; } - // Account for flat or expandable Checklist options - options = - options || groupedOptions?.map((group) => group.children)?.flat(); if (values.fn && !options?.some((option) => option.data.val)) { errors.fn = "At least one option must set a data value when the checklist has a data field"; @@ -164,7 +164,7 @@ export const ChecklistEditor: React.FC = (props) => { onChange={() => formik.setFieldValue( "allRequired", - !formik.values.allRequired + !formik.values.allRequired, ) } label="All required" @@ -177,7 +177,7 @@ export const ChecklistEditor: React.FC = (props) => { onChange={() => formik.setFieldValue( "neverAutoAnswer", - !formik.values.neverAutoAnswer + !formik.values.neverAutoAnswer, ) } label="Always put to user (forgo automation)" diff --git a/editor.planx.uk/src/@planx/components/Checklist/Editor/Options.tsx b/editor.planx.uk/src/@planx/components/Checklist/Editor/Options.tsx index 13d2afa804..232f9f7039 100644 --- a/editor.planx.uk/src/@planx/components/Checklist/Editor/Options.tsx +++ b/editor.planx.uk/src/@planx/components/Checklist/Editor/Options.tsx @@ -1,213 +1,74 @@ -import Delete from "@mui/icons-material/Delete"; -import Box from "@mui/material/Box"; -import Button from "@mui/material/Button"; -import IconButton from "@mui/material/IconButton"; -import { BaseOptionsEditor } from "@planx/components/shared/BaseOptionsEditor"; +import { getOptionsSchemaByFn } from "@planx/components/shared/utils"; import { hasFeatureFlag } from "lib/featureFlags"; import { partition } from "lodash"; -import adjust from "ramda/src/adjust"; -import compose from "ramda/src/compose"; -import remove from "ramda/src/remove"; import React from "react"; import { FormikHookReturn } from "types"; import ListManager from "ui/editor/ListManager/ListManager"; import ModalSectionContent from "ui/editor/ModalSectionContent"; -import ErrorWrapper from "ui/shared/ErrorWrapper"; -import Input from "ui/shared/Input/Input"; -import InputRow from "ui/shared/InputRow"; -import { getOptionsSchemaByFn } from "@planx/components/shared/utils"; -import { useStore } from "pages/FlowEditor/lib/store"; import { Option } from "../../shared"; -import type { Group } from "../model"; -import ChecklistOptionsEditor from "./OptionsEditor"; +import { useInitialOptions } from "../Public/hooks/useInitialOptions"; +import { ExclusiveOrOptionManager } from "./components/ExclusiveOrOptionManager"; +import { GroupedOptions } from "./components/GroupedOptions"; +import ChecklistOptionsEditor from "./components/OptionsEditor"; export const Options: React.FC<{ formik: FormikHookReturn }> = ({ formik }) => { const [exclusiveOptions, nonExclusiveOptions]: Option[][] = partition( formik.values.options, - (option) => option.data.exclusive + (option) => option.data.exclusive, ); const exclusiveOrOptionManagerShouldRender = - hasFeatureFlag("EXCLUSIVE_OR") && nonExclusiveOptions.length; - - const schema = useStore().getFlowSchema()?.options; - const initialOptions: Option[] | undefined = formik.initialValues.options || formik.initialValues.groupedOptions?.map((group: Group