Skip to content

Commit

Permalink
fix for placeholder ids (#151)
Browse files Browse the repository at this point in the history
* fix for placeholder ids

* fix snapshot
  • Loading branch information
martyncolmer authored Feb 10, 2023
1 parent eaf60ba commit 4b3b914
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ SummaryBlock {
"item_title": Object {
"placeholders": Array [
Object {
"placeholder": "item-text-listcollector-1",
"placeholder": "listcollector_summary_placeholder",
"transforms": Array [
Object {
"arguments": Object {
Expand All @@ -91,7 +91,7 @@ SummaryBlock {
],
},
],
"text": "{item-text-listcollector-1}",
"text": "{listcollector_summary_placeholder}",
},
"title": "Summary",
}
Expand Down
4 changes: 2 additions & 2 deletions src/eq_schema/block-types/listCollector/summaryBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class SummaryBlock {
this.title = "Summary"
const listAnswers = getList(ctx, page.listId).answers
this.item_title = {
text: `{item-text-${page.id}}`,
text: `{listcollector_summary_placeholder}`,
placeholders: [
{
placeholder: `item-text-${page.id}`,
placeholder: `listcollector_summary_placeholder`,
transforms: [
{
arguments: {
Expand Down
3 changes: 2 additions & 1 deletion src/eq_schema/schema/Questionnaire/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { contentMap } = require("../../../constants/legalBases");

const { buildContents } = require("../../../utils/builders");
const { buildContents, formatListNames } = require("../../../utils/builders");

const { validThemes, themeNames } = require("../../../constants/validThemes");

Expand All @@ -26,6 +26,7 @@ const getTheme = (previewTheme) => {

class Questionnaire {
constructor(questionnaireJson) {
formatListNames(questionnaireJson)
const { surveyId } = questionnaireJson;
const { formType, legalBasisCode } = getPreviewTheme(
questionnaireJson.themeSettings
Expand Down
4 changes: 2 additions & 2 deletions src/eq_schema/schema/Section/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ class Section {
};

this.repeat.title = {
text: `{item-text-${section.id}}`,
text: `{repeat_title_placeholder}`,
placeholders: [
{
placeholder: `item-text-${section.id}`,
placeholder: `repeat_title_placeholder`,
transforms: [
{
arguments: {
Expand Down
11 changes: 11 additions & 0 deletions src/utils/builders/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,18 @@ const buildIntroductionTitle = () => {
};
};

const formatListNames = (questionnaire) => {
questionnaire.collectionLists.lists.forEach(
(list) => {
list.listName = list.listName.replace(/ /g,'_');
list.listName = list.listName.replace(/-/g,'_');
list.listName = list.listName.toLowerCase()
}
)
}

module.exports = {
buildContents,
buildIntroductionTitle,
formatListNames,
};

0 comments on commit 4b3b914

Please sign in to comment.