-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert publications to local rendering #3058
Conversation
730445c
to
26cbc4f
Compare
2ddeea0
to
93a7811
Compare
- create a new partial for use and modification by publications - currently just a copy of the existing _attachments.html.erb
93a7811
to
6a1c119
Compare
- modify the new partial and the publication presenter to use a different bit of the content item for generating the attachments list - specifically, use `details->attachments` instead of `details->documents`, which is pre-rendered HTML - `details->attachments` contains only the data for the attachments, allowing us to render them individually in the new partial using frontend components, which will allow us to add tracking later
- Add override data to support publication test - Update tests to make more relevant
fa280ed
to
2f5cdec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got the review app going to test it and it looks good! 💯
@@ -11,7 +11,8 @@ def details | |||
end | |||
|
|||
def documents | |||
content_item["details"]["documents"].to_a.join("") | |||
docs = content_item["details"]["attachments"].select { |a| a["locale"] == locale } if content_item["details"]["attachments"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, this is clever, so you only display attachments with the same locale as the page. Nice!
<%= render 'govuk_publishing_components/components/attachment', { | ||
heading_level: 3, | ||
attachment: details, | ||
margin_bottom: 6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍
What
Rework form (publication) pages to render attachments locally in the application, rather than using the pre-rendered chunk of markup from the content item.
Specifically, rework the list of documents on the forms pages to use the content item data in
details->attachments
to render the required content, in place of the data indetails->documents
, which is pre-rendered. This has involved the creation of a new partial for publication pages, as the existing partial is used by other page types.Example form pages:
Why
Relates to previous work in alphagov/govuk_publishing_components#3820
Reworked version of changes in #3048
We need to put tracking on the details components that can (sometimes) appear beneath the list of attachments, and that's very hard to do here on pre-rendered markup - normally we'd just pass some options to the component. This work will be carried out in a follow up PR.
Visual changes
details->attachments
doesn't include custom thumbnails for PDFs, as previously displayed. We looked at getting this included in the content item, but ultimately decided with consultation from leads that the default thumbnail for PDFs is acceptable. This is for several reasons:With the new data it looks like the attachments display the
Request an accessible format
option more than they used to. This seems to be valid (it happens if you pass an email address to the component via thealternative_format_contact_email
option) and allowing users this option more often seems sensible, but it raises the question why some PDFs used to have this option and some didn't.See example below. Note how before only some of these PDFs had the accessible format option, but now all of them have.
Trello card: https://trello.com/c/xhASj1rp/765-add-tracking-to-details-component