From b167ba07996a96b305000a72cab877a394e31d4c Mon Sep 17 00:00:00 2001 From: martyncolmer Date: Thu, 25 Jan 2024 12:26:47 +0000 Subject: [PATCH 1/2] update piping on intro page for prepop --- .../__snapshots__/index.test.js.snap | 6 +++++ .../Design/IntroductionEditor/index.js | 7 +++++ .../components/RichTextEditor/PipingMenu.js | 27 +++++++++++-------- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/eq-author/src/App/introduction/Design/IntroductionEditor/__snapshots__/index.test.js.snap b/eq-author/src/App/introduction/Design/IntroductionEditor/__snapshots__/index.test.js.snap index 55e02ee5fd..2a54fe0262 100644 --- a/eq-author/src/App/introduction/Design/IntroductionEditor/__snapshots__/index.test.js.snap +++ b/eq-author/src/App/introduction/Design/IntroductionEditor/__snapshots__/index.test.js.snap @@ -37,6 +37,7 @@ exports[`IntroductionEditor should render 1`] = ` multiline={true} name="title" onUpdate={[Function]} + pageType="Introduction" placeholder="" size="large" testSelector="txt-intro-title" @@ -190,6 +191,7 @@ exports[`IntroductionEditor should render 1`] = ` multiline={true} name="description" onUpdate={[Function]} + pageType="Introduction" placeholder="" testSelector="txt-intro-description" value="description" @@ -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" @@ -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" @@ -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" @@ -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" diff --git a/eq-author/src/App/introduction/Design/IntroductionEditor/index.js b/eq-author/src/App/introduction/Design/IntroductionEditor/index.js index 94c626a339..28761ce7a2 100644 --- a/eq-author/src/App/introduction/Design/IntroductionEditor/index.js +++ b/eq-author/src/App/introduction/Design/IntroductionEditor/index.js @@ -147,6 +147,7 @@ const IntroductionEditor = ({ introduction, history }) => { id="intro-title" name="title" label="Title" + pageType="Introduction" multiline value={title} size="large" @@ -305,6 +306,7 @@ const IntroductionEditor = ({ introduction, history }) => { @@ -331,6 +333,7 @@ const IntroductionEditor = ({ introduction, history }) => { id="intro-description" name="description" label="Description" + pageType="Introduction" multiline value={description} controls={descriptionControls} @@ -424,6 +427,7 @@ const IntroductionEditor = ({ introduction, history }) => { id="secondary-title" name="secondaryTitle" label="Title" + pageType="Introduction" value={secondaryTitle} controls={titleControls} size="large" @@ -442,6 +446,7 @@ const IntroductionEditor = ({ introduction, history }) => { id="secondary-description" name="secondaryDescription" label="Description" + pageType="Introduction" multiline value={secondaryDescription} controls={descriptionControls} @@ -472,6 +477,7 @@ const IntroductionEditor = ({ introduction, history }) => { id="tertiary-title" name="tertiaryTitle" label="Title" + pageType="Introduction" value={tertiaryTitle} controls={titleControls} size="large" @@ -490,6 +496,7 @@ const IntroductionEditor = ({ introduction, history }) => { id="tertiary-description" name="tertiaryDescription" label="Description" + pageType="Introduction" multiline value={tertiaryDescription} controls={descriptionControls} diff --git a/eq-author/src/components/RichTextEditor/PipingMenu.js b/eq-author/src/components/RichTextEditor/PipingMenu.js index 21a787ddef..b7a8057f8e 100644 --- a/eq-author/src/components/RichTextEditor/PipingMenu.js +++ b/eq-author/src/components/RichTextEditor/PipingMenu.js @@ -117,17 +117,22 @@ 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") { + 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) { From f992d8fe7e99434dcfbd795f1ce79d91fc09a003 Mon Sep 17 00:00:00 2001 From: martyncolmer Date: Thu, 25 Jan 2024 12:40:22 +0000 Subject: [PATCH 2/2] tweak to stop piping if first section is not repeating --- eq-author/src/components/RichTextEditor/PipingMenu.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eq-author/src/components/RichTextEditor/PipingMenu.js b/eq-author/src/components/RichTextEditor/PipingMenu.js index b7a8057f8e..c26b61a90f 100644 --- a/eq-author/src/components/RichTextEditor/PipingMenu.js +++ b/eq-author/src/components/RichTextEditor/PipingMenu.js @@ -119,7 +119,10 @@ const PipingMenu = ({ let allSupplementaryData = questionnaire?.supplementaryData?.data || []; - if (allSupplementaryData && pageType !== "Introduction") { + if ( + allSupplementaryData && + !(pageType === "Introduction" && questionnaire.sections[0].repeatingSection) + ) { allSupplementaryData = allSupplementaryData.filter( (list) => list.listName === "" || list.id === listId );