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

Production deploy #3916

Merged
merged 1 commit into from
Nov 6, 2024
Merged
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
13 changes: 2 additions & 11 deletions editor.planx.uk/src/@planx/components/Checklist/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import FormControlLabel from "@mui/material/FormControlLabel";
import IconButton from "@mui/material/IconButton";
import Switch from "@mui/material/Switch";
import { ComponentType as TYPES } from "@opensystemslab/planx-core/types";
import { FormikErrors, FormikValues, useFormik } from "formik";
import { useFormik } from "formik";
import adjust from "ramda/src/adjust";
import compose from "ramda/src/compose";
import remove from "ramda/src/remove";
Expand Down Expand Up @@ -312,14 +312,7 @@ export const ChecklistComponent: React.FC<ChecklistProps> = (props) => {
alert(JSON.stringify({ type, ...values, options }, null, 2));
}
},
validate: ({ options, ...values }) => {
const errors: FormikErrors<FormikValues> = {};
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";
}
return errors;
},
validate: () => {},
});

const focusRef = useRef<HTMLInputElement | null>(null);
Expand Down Expand Up @@ -372,8 +365,6 @@ export const ChecklistComponent: React.FC<ChecklistProps> = (props) => {
value={formik.values.fn}
placeholder="Data Field"
onChange={formik.handleChange}
error={Boolean(formik.errors?.fn)}
errorMessage={formik.errors?.fn}
/>
</InputRow>
<InputRow>
Expand Down
20 changes: 4 additions & 16 deletions editor.planx.uk/src/@planx/components/Question/Editor.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import FormControlLabel from "@mui/material/FormControlLabel";
import Switch from "@mui/material/Switch";
import { ComponentType as TYPES } from "@opensystemslab/planx-core/types";
import { FormikErrors, FormikValues, useFormik } from "formik";
import { useFormik } from "formik";
import React, { useEffect, useRef } from "react";
import { ComponentTagSelect } from "ui/editor/ComponentTagSelect";
import ImgInput from "ui/editor/ImgInput/ImgInput";
Expand Down Expand Up @@ -109,11 +109,7 @@ const OptionEditor: React.FC<{
</InputRow>
)}
<FlagsSelect
value={
Array.isArray(props.value.data.flag)
? props.value.data.flag
: [props.value.data.flag]
}
value={Array.isArray(props.value.data.flag) ? props.value.data.flag : [props.value.data.flag]}
onChange={(ev) => {
props.onChange({
...props.value,
Expand Down Expand Up @@ -155,14 +151,7 @@ export const Question: React.FC<Props> = (props) => {
alert(JSON.stringify({ type, ...values, children }, null, 2));
}
},
validate: ({ options, ...values }) => {
const errors: FormikErrors<FormikValues> = {};
if (values.fn && !options.some((option) => option.data.val)) {
errors.fn =
"At least one option must set a data value when the question has a data field";
}
return errors;
},
validate: () => { },
});

const focusRef = useRef<HTMLInputElement | null>(null);
Expand Down Expand Up @@ -212,8 +201,6 @@ export const Question: React.FC<Props> = (props) => {
value={formik.values.fn}
placeholder="Data Field"
onChange={formik.handleChange}
error={Boolean(formik.errors?.fn)}
errorMessage={formik.errors?.fn}
/>
</InputRow>
<InputRow>
Expand All @@ -234,6 +221,7 @@ export const Question: React.FC<Props> = (props) => {
</InputRow>
</InputGroup>
</ModalSectionContent>

<ModalSectionContent subtitle="Options">
<ListManager
values={formik.values.options}
Expand Down
7 changes: 3 additions & 4 deletions editor.planx.uk/src/pages/FlowEditor/lib/store/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,12 +514,11 @@ export const previewStore: StateCreator<
)
return;

// Only proceed if the user has seen at least one node with this fn (or `output` in case of Calculate nodes) before
// Only proceed if the user has seen at least one node with this fn before
const visitedFns = Object.entries(breadcrumbs).filter(
([nodeId, _breadcrumb]) =>
[flow[nodeId].data?.fn, flow[nodeId].data?.output].includes(data.fn),
([nodeId, _breadcrumb]) => flow[nodeId].data?.fn === data.fn,
);
if (!visitedFns.length) return;
if (!visitedFns) return;

// Get all options (aka edges or Answer nodes) for this node
const options: Array<Store.Node> = edges.map((edgeId) => ({
Expand Down