Skip to content

Commit

Permalink
Merge pull request #1430 from alphagov/hide-order-copy-link-from-admins
Browse files Browse the repository at this point in the history
Add 'hide_order_copy_link' parameter to hide 'Order a copy'
  • Loading branch information
ChrisBAshton authored Apr 3, 2020
2 parents 18bb715 + 7672fa3 commit bbeaff4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
useful summary for people upgrading their application, not a replication
of the commit log.

## Unreleased

* Add 'hide_order_copy_link' parameter to hide 'Order a copy' ([PR #1430](https://github.com/alphagov/govuk_publishing_components/pull/1430))

## 21.38.3

* Update yellow hex code for Public Health England ([PR #1428](https://github.com/alphagov/govuk_publishing_components/pull/1428))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
attachment = GovukPublishingComponents::Presenters::Attachment.new(attachment)
target ||= "_self"
hide_opendocument_metadata ||= false
hide_order_copy_link ||= false
attributes = []
data_attributes ||= {}

Expand Down Expand Up @@ -68,7 +69,7 @@
<%= tag.p raw(attributes.join(', ')), class: "gem-c-attachment__metadata" %>
<% end %>

<% if attachment.is_official_document %>
<% if attachment.is_official_document && !hide_order_copy_link %>
<%= tag.p link_to("Order a copy", "https://www.gov.uk/guidance/how-to-buy-printed-copies-of-official-documents", class: "govuk-link govuk-link--no-visited-state", target: "_blank"),
class: "gem-c-attachment__metadata" %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,18 @@ examples:
isbn: "978-1-913635-01-5"
unique_reference: "2942"
unnumbered_hoc_paper: true
hide_order_a_copy:
description: |
With 'Order a copy' hidden
data:
attachment:
title: "Budget 2020"
url: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/871799/Budget_2020_Web_Accessible_Complete.pdf
filename: Budget_2020_Web_Accessible_Complete.pdf
content_type: application/pdf
file_size: 20000
number_of_pages: 12
isbn: "978-1-913635-01-5"
unique_reference: "2942"
unnumbered_hoc_paper: true
hide_order_copy_link: true
17 changes: 17 additions & 0 deletions spec/components/attachment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,21 @@ def component_name
)
assert_select ".gem-c-attachment__metadata:nth-of-type(3) .govuk-link", text: "Order a copy"
end

it "does not show 'Order a copy' link if disabled" do
render_component(
attachment: {
title: "The government financial reporting review",
url: "https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/791567/the_government_financial_reporting_review_web.pdf",
filename: "department-for-transport-information-asset-register.csv",
content_type: "application/pdf",
file_size: 20000,
number_of_pages: 7,
isbn: "978-1-5286-1173-2",
command_paper_number: "Cd. 67",
},
hide_order_copy_link: true,
)
assert_select ".gem-c-attachment__metadata:nth-of-type(3) .govuk-link", false
end
end

0 comments on commit bbeaff4

Please sign in to comment.