Skip to content

Commit

Permalink
fix for section summary (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
martyncolmer authored Dec 15, 2023
1 parent bc9fd5b commit c71773d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
11 changes: 3 additions & 8 deletions src/eq_schema/schema/Section/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class Section {
});

this.summary.items = items;
this.summary.show_non_item_answers = true;
}

if ("showOnHub" in section) {
Expand Down Expand Up @@ -151,20 +152,14 @@ class Section {

static buildItem(itemId, listCollectorTitle, ctx) {
const list = getList(ctx, itemId);
const anchorListItems = list.answers;
const [anchorItem, ...relatedItems] = anchorListItems;
const relatedAnswers = relatedItems.map((answer) => ({
source: "answers",
identifier: `answer${answer.id}`,
}));
let anchorItem = list.answers[0];

const ListCollectorsSummary = {
type: "List",
for_list: list.listName,
title: processPipe(ctx)(listCollectorTitle),
item_anchor_answer_id: anchorItem.id,
item_anchor_answer_id: `answer${anchorItem.id}`,
item_label: anchorItem.label,
related_answers: relatedAnswers,
add_link_text: "Add item to this list",
empty_list_text: "There are no items",
};
Expand Down
13 changes: 2 additions & 11 deletions src/eq_schema/schema/Section/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,22 +453,13 @@ describe("Section", () => {
type: "List",
for_list: "test3",
title: "What is the name of this person?",
item_anchor_answer_id: "cdea9794-6f3c-40c1-9de4-8bbe6e7c54b5",
item_anchor_answer_id: "answercdea9794-6f3c-40c1-9de4-8bbe6e7c54b5",
item_label: "<p>Text 1</p>",
related_answers: [
{
source: "answers",
identifier: "answer57bdaf77-7f36-40f1-9994-e91862a95059",
},
{
source: "answers",
identifier: "answer43ee1461-e363-493f-90cc-d515a205efeb",
},
],
add_link_text: "Add item to this list",
empty_list_text: "There are no items",
},
],
show_non_item_answers: true,
},
});
});
Expand Down

0 comments on commit c71773d

Please sign in to comment.