Skip to content

Commit

Permalink
Merge pull request #3093 from ONSdigital/Update-to-piping-in-introduc…
Browse files Browse the repository at this point in the history
…tion-page-for-prepop

update piping on intro page for prepop
  • Loading branch information
martyncolmer authored Jan 25, 2024
2 parents 9e6d9f2 + f992d8f commit f0a779b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ exports[`IntroductionEditor should render 1`] = `
multiline={true}
name="title"
onUpdate={[Function]}
pageType="Introduction"
placeholder=""
size="large"
testSelector="txt-intro-title"
Expand Down Expand Up @@ -190,6 +191,7 @@ exports[`IntroductionEditor should render 1`] = `
multiline={true}
name="description"
onUpdate={[Function]}
pageType="Introduction"
placeholder=""
testSelector="txt-intro-description"
value="description"
Expand Down Expand Up @@ -290,6 +292,7 @@ exports[`IntroductionEditor should render 1`] = `
multiline={false}
name="secondaryTitle"
onUpdate={[Function]}
pageType="Introduction"
placeholder=""
size="large"
testSelector="txt-intro-secondary-title"
Expand All @@ -313,6 +316,7 @@ exports[`IntroductionEditor should render 1`] = `
multiline={true}
name="secondaryDescription"
onUpdate={[Function]}
pageType="Introduction"
placeholder=""
testSelector="txt-intro-secondary-description"
value="secondary description"
Expand Down Expand Up @@ -355,6 +359,7 @@ exports[`IntroductionEditor should render 1`] = `
multiline={false}
name="tertiaryTitle"
onUpdate={[Function]}
pageType="Introduction"
placeholder=""
size="large"
testSelector="txt-intro-tertiary-title"
Expand All @@ -378,6 +383,7 @@ exports[`IntroductionEditor should render 1`] = `
multiline={true}
name="tertiaryDescription"
onUpdate={[Function]}
pageType="Introduction"
placeholder=""
testSelector="txt-intro-tertiary-description"
value="tertiary description"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ const IntroductionEditor = ({ introduction, history }) => {
id="intro-title"
name="title"
label="Title"
pageType="Introduction"
multiline
value={title}
size="large"
Expand Down Expand Up @@ -305,6 +306,7 @@ const IntroductionEditor = ({ introduction, history }) => {
<RichTextEditor
id={`details-additionalGuidancePanel-${id}`}
name="additionalGuidancePanel"
pageType="Introduction"
value={additionalGuidancePanel}
label=""
onUpdate={({ value }) =>
Expand All @@ -331,6 +333,7 @@ const IntroductionEditor = ({ introduction, history }) => {
id="intro-description"
name="description"
label="Description"
pageType="Introduction"
multiline
value={description}
controls={descriptionControls}
Expand Down Expand Up @@ -424,6 +427,7 @@ const IntroductionEditor = ({ introduction, history }) => {
id="secondary-title"
name="secondaryTitle"
label="Title"
pageType="Introduction"
value={secondaryTitle}
controls={titleControls}
size="large"
Expand All @@ -442,6 +446,7 @@ const IntroductionEditor = ({ introduction, history }) => {
id="secondary-description"
name="secondaryDescription"
label="Description"
pageType="Introduction"
multiline
value={secondaryDescription}
controls={descriptionControls}
Expand Down Expand Up @@ -472,6 +477,7 @@ const IntroductionEditor = ({ introduction, history }) => {
id="tertiary-title"
name="tertiaryTitle"
label="Title"
pageType="Introduction"
value={tertiaryTitle}
controls={titleControls}
size="large"
Expand All @@ -490,6 +496,7 @@ const IntroductionEditor = ({ introduction, history }) => {
id="tertiary-description"
name="tertiaryDescription"
label="Description"
pageType="Introduction"
multiline
value={tertiaryDescription}
controls={descriptionControls}
Expand Down
30 changes: 19 additions & 11 deletions eq-author/src/components/RichTextEditor/PipingMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,25 @@ const PipingMenu = ({

const listAllAnswers = [...listAnswers, ...listCollectorFollowUpAnswers];

const supplementaryData =
questionnaire?.supplementaryData?.data
.filter((list) => list.listName === "" || list.id === listId)
.flatMap((list) => {
return list.schemaFields.map((schemaField) => {
return {
listName: list.listName,
...schemaField,
};
});
}) || [];
let allSupplementaryData = questionnaire?.supplementaryData?.data || [];

if (
allSupplementaryData &&
!(pageType === "Introduction" && questionnaire.sections[0].repeatingSection)
) {
allSupplementaryData = allSupplementaryData.filter(
(list) => list.listName === "" || list.id === listId
);
}

const supplementaryData = allSupplementaryData.flatMap((list) => {
return list.schemaFields.map((schemaField) => {
return {
listName: list.listName,
...schemaField,
};
});
});

const handlePickerContent = (contentType) => {
switch (contentType) {
Expand Down

0 comments on commit f0a779b

Please sign in to comment.