Skip to content

Commit

Permalink
Merge pull request #3107 from ONSdigital/EAR-2367-list-additional-pag…
Browse files Browse the repository at this point in the history
…e-answer-piping

EAR 2367 Add piping for answer labels in list additional pages
  • Loading branch information
farres1 authored Mar 28, 2024
2 parents 3f3b74d + a291851 commit 4b3d30b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
8 changes: 8 additions & 0 deletions eq-author-api/schema/resolvers/utils/folderGetters.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ const getFolderById = (ctx, id) => find(getFolders(ctx), { id });
const getFolderByPageId = (ctx, id) =>
find(getFolders(ctx), ({ pages }) => pages && some(pages, { id }));

const getFolderByAnswerId = (ctx, id) =>
find(
getFolders(ctx),
({ pages }) =>
pages && some(pages, ({ answers }) => answers && some(answers, { id }))
);

module.exports = {
getFolders,
getFoldersBySectionId,
getFolderById,
getFolderByPageId,
getFolderByAnswerId,
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const {
idExists,
getListByAnswerId,
getSupplementaryDataAsCollectionListbyFieldId,
getFolderByAnswerId,
} = require("../../../schema/resolvers/utils");

const pipedAnswerIdRegex =
Expand All @@ -31,6 +32,7 @@ module.exports = (ajv) =>
rootData: questionnaire,
}
) {
const folder = getFolderByAnswerId({ questionnaire }, parentData.id);
isValid.errors = [];
const pipedIdList = [];

Expand Down Expand Up @@ -78,8 +80,9 @@ module.exports = (ajv) =>
if (list) {
if (!(dataPiped === "supplementary" && list.listName === "")) {
if (
list.id !== parentData.repeatingLabelAndInputListId ||
!parentData.repeatingLabelAndInput
!folder.listId &&
(list.id !== parentData.repeatingLabelAndInputListId ||
!parentData.repeatingLabelAndInput)
) {
return hasError(PIPING_TITLE_DELETED);
}
Expand Down
7 changes: 6 additions & 1 deletion eq-author/src/App/page/Design/answers/BasicAnswer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,12 @@ export const StatelessBasicAnswer = ({
controls={pipingControls}
size="large"
allowableTypes={[ANSWER, METADATA]}
listId={answer.repeatingLabelAndInputListId ?? null}
listId={
(answer.repeatingLabelAndInputListId ||
page.section?.repeatingSectionListId ||
page.folder?.listId) ??
null
}
hasLabelErrors={hasLabelErrors(answer.validationErrorInfo?.errors)}
autoFocus={!answer.label}
/>
Expand Down

0 comments on commit 4b3d30b

Please sign in to comment.