{"action":"closed","issue":{"url":"https://api.github.com/repos/hmcts/one-per-page/issues/93","repository_url":"https://api.github.com/repos/hmcts/one-per-page","labels_url":"https://api.github.com/repos/hmcts/one-per-page/issues/93/labels{/name}","comments_url":"https://api.github.com/repos/hmcts/one-per-page/issues/93/comments","events_url":"https://api.github.com/repos/hmcts/one-per-page/issues/93/events","html_url":"https://github.com/hmcts/one-per-page/issues/93","id":293847654,"number":93,"title":"Render arbitrary HTML in answers on Check your Answers","user":{"login":"michaeldfallen","id":1446145,"avatar_url":"https://avatars0.githubusercontent.com/u/1446145?v=4","gravatar_id":"","url":"https://api.github.com/users/michaeldfallen","html_url":"https://github.com/michaeldfallen","followers_url":"https://api.github.com/users/michaeldfallen/followers","following_url":"https://api.github.com/users/michaeldfallen/following{/other_user}","gists_url":"https://api.github.com/users/michaeldfallen/gists{/gist_id}","starred_url":"https://api.github.com/users/michaeldfallen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaeldfallen/subscriptions","organizations_url":"https://api.github.com/users/michaeldfallen/orgs","repos_url":"https://api.github.com/users/michaeldfallen/repos","events_url":"https://api.github.com/users/michaeldfallen/events{/privacy}","received_events_url":"https://api.github.com/users/michaeldfallen/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"michaeldfallen","id":1446145,"avatar_url":"https://avatars0.githubusercontent.com/u/1446145?v=4","gravatar_id":"","url":"https://api.github.com/users/michaeldfallen","html_url":"https://github.com/michaeldfallen","followers_url":"https://api.github.com/users/michaeldfallen/followers","following_url":"https://api.github.com/users/michaeldfallen/following{/other_user}","gists_url":"https://api.github.com/users/michaeldfallen/gists{/gist_id}","starred_url":"https://api.github.com/users/michaeldfallen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaeldfallen/subscriptions","organizations_url":"https://api.github.com/users/michaeldfallen/orgs","repos_url":"https://api.github.com/users/michaeldfallen/repos","events_url":"https://api.github.com/users/michaeldfallen/events{/privacy}","received_events_url":"https://api.github.com/users/michaeldfallen/received_events","type":"User","site_admin":false},"assignees":[{"login":"michaeldfallen","id":1446145,"avatar_url":"https://avatars0.githubusercontent.com/u/1446145?v=4","gravatar_id":"","url":"https://api.github.com/users/michaeldfallen","html_url":"https://github.com/michaeldfallen","followers_url":"https://api.github.com/users/michaeldfallen/followers","following_url":"https://api.github.com/users/michaeldfallen/following{/other_user}","gists_url":"https://api.github.com/users/michaeldfallen/gists{/gist_id}","starred_url":"https://api.github.com/users/michaeldfallen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaeldfallen/subscriptions","organizations_url":"https://api.github.com/users/michaeldfallen/orgs","repos_url":"https://api.github.com/users/michaeldfallen/repos","events_url":"https://api.github.com/users/michaeldfallen/events{/privacy}","received_events_url":"https://api.github.com/users/michaeldfallen/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2018-02-02T10:50:32Z","updated_at":"2018-02-20T16:11:02Z","closed_at":"2018-02-20T16:11:02Z","author_association":"CONTRIBUTOR","body":"Currently, answer blocks are quite restrictive, allowing only simple JS values like strings and arrays to be rendered.\r\n\r\nSSCS have a design that requires a custom layout for a question in Check Your Answers:\r\n\r\n![image](https://user-images.githubusercontent.com/1446145/35729197-e3e4e410-0805-11e8-84ab-48719a1f5a50.png)\r\n\r\nTo do this they would need a way to load a template and render it, with the step that produced it as the local scope, during the rendering of CYA.\r\n\r\nA suggested interface is:\r\n```js\r\nclass MyStep extends Question {\r\n  answers() {\r\n    return answer(this, {\r\n      question: \"Reasons for Appealing\",\r\n      template: 'ReasonsForAppealing.answer.html'\r\n    });\r\n  }\r\n}\r\n```\r\n\r\nDuring CYA we would iterate through each answer from `RequestBoundJourney.collectAnswers` and resolve and render the template into an `answer.html` parameter.\r\n\r\n```js\r\n  get answers() {\r\n    if (notDefined(this.visitedSteps)) {\r\n      throw new StepsNotCollected(this.req.currentStep.name);\r\n    }\r\n    const answerPromises = this.visitedSteps\r\n      .map(step => step.answers())\r\n      .map(renderAnswers);\r\n    return Promise.all(answerPromises);\r\n  }\r\n```\r\n\r\nCheck Your answers would then need to wait for the promise returned to resolve (or timeout) and then render the CYA step."}}
{"actor":{"display_login":"michaeldfallen"}}