Skip to content

Commit 8c3b8f4

Browse files
committed
added reverse piping
Signed-off-by: Martyn <46242834+martyncolmer@users.noreply.github.com>
1 parent eb5347b commit 8c3b8f4

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/eq_schema/schema/Block/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ const processPipe = (ctx, isMultipleChoiceValue = false, isRepeatingSection = fa
3434
getInnerHTMLWithPiping
3535
);
3636

37-
const reversePipe = (ctx) =>
38-
flow(wrapContents("contents"), reversePipeContent(ctx));
37+
const reversePipe = (ctx, isMultipleChoiceValue = false, isRepeatingSection = false) =>
38+
flow(wrapContents("contents"), reversePipeContent(ctx, isMultipleChoiceValue, isRepeatingSection));
3939

4040
const isLastPageInSection = (page, ctx) =>
4141
flow(getOr([], "sections"), map(getLastPage), some({ id: page.id }))(ctx);
@@ -104,7 +104,7 @@ class Block {
104104
page_title: processPipe(ctx, false, isRepeatingSection)(introductionPageDescription),
105105
content: {
106106
title: processPipe(ctx, false, isRepeatingSection)(introductionTitle) || "",
107-
contents: reversePipe(ctx)(introductionContent).contents,
107+
contents: reversePipe(ctx, false, isRepeatingSection)(introductionContent).contents,
108108
},
109109
};
110110
}

src/utils/compoundFunctions/index.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ const { flow } = require("lodash/fp");
22
const { parseContent, getInnerHTMLWithPiping } = require("../HTMLUtils");
33
const convertPipes = require("../convertPipes");
44

5-
const processPipe = (ctx) => flow(convertPipes(ctx), getInnerHTMLWithPiping);
5+
const processPipe = (ctx, isMultipleChoiceValue = false, isRepeatingSection = false) =>
6+
flow(
7+
convertPipes(ctx, isMultipleChoiceValue, isRepeatingSection),
8+
getInnerHTMLWithPiping
9+
);
610

711
const wrapContents = (propName) => (content) => {
812
if (!propName || propName === "" || !content) {
@@ -17,7 +21,7 @@ const wrapContents = (propName) => (content) => {
1721
return { [propName]: result };
1822
};
1923

20-
const reversePipeContent = (ctx) => (data) => {
24+
const reversePipeContent = (ctx, isMultipleChoiceValue = false, isRepeatingSection = false) => (data) => {
2125
if (!data) {
2226
return "";
2327
}
@@ -29,7 +33,7 @@ const reversePipeContent = (ctx) => (data) => {
2933
items.list = items.list.map((item) => processPipe(ctx)(item));
3034
}
3135
if (items.description) {
32-
items.description = processPipe(ctx)(items.description);
36+
items.description = processPipe(ctx, isMultipleChoiceValue, isRepeatingSection)(items.description);
3337
}
3438
return items;
3539
});

0 commit comments

Comments
 (0)