Skip to content

Commit

Permalink
Remove overview text
Browse files Browse the repository at this point in the history
The context_label is being defined by "schema_name: "publication" - should this be present this determines whether we class this as a "publication or consultation"

Ensure title of page has "context_inside" Content prefixed to a "publication or consultation"

Should content be [withdrawn] this also adds the "context_label" (or grey text) to the title scoped to items that have been identified as a "publication or consultation"

Remove the loops around the attachments and just apply the context_label in all cases.

Remove word "overview" from "context_inside"
  • Loading branch information
Chris Yoong committed Dec 1, 2021
1 parent dab1815 commit cbc845a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 25 deletions.
29 changes: 28 additions & 1 deletion app/presenters/content_item/withdrawable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ def withdrawn?
end

def page_title
withdrawn? ? "[Withdrawn] #{title}" : title
if withdrawn? && context_title? && publication_overview?
"[Withdrawn] #{context_title}: #{title}"
elsif withdrawn?
"[Withdrawn] #{title}"
elsif context_title? && publication_overview?
"#{context_title}: #{title}"
else
title
end
end

def withdrawal_notice_component
Expand All @@ -21,6 +29,19 @@ def withdrawal_notice_component

private

def context_title?
context_title.present?
end

def publication_overview?
publication_overview.present?
end

def publication_overview
overview = (I18n.exists?("content_item.#{schema_name}") == "publication" || "statistical_data_set")
overview.presence
end

def withdrawal_notice
content_item["withdrawn_notice"]
end
Expand All @@ -29,6 +50,12 @@ def withdrawal_notice_title
"This #{withdrawal_notice_context.downcase} was withdrawn on #{withdrawal_notice_time}".html_safe
end

def context_title
if I18n.exists?("content_item.schema_name.#{document_type}", count: 1, locale: :en)
I18n.t("content_item.schema_name.#{document_type}", count: 1, locale: :en)
end
end

def withdrawal_notice_context
I18n.t("content_item.schema_name.#{schema_name}", count: 1, locale: :en)
end
Expand Down
25 changes: 3 additions & 22 deletions app/views/content_items/_context_and_title.html.erb
Original file line number Diff line number Diff line change
@@ -1,26 +1,7 @@
<%
context_string = t("content_item.schema_name.#{@content_item.document_type}", count: 1);
context_inside = false;
%>
<% @content_item&.featured_attachments.each do |fa| %>
<% return if !@content_item.attachment_details(fa).present? %>
<% if @content_item.attachment_details(fa)['title'] == @content_item.title %>
<% content_for :title do %>
<%= t("content_item.schema_name.#{@content_item.document_type}.overview", count: 1) %>: <%= @content_item.title %>
<% end %>
<%
context_string = t("content_item.schema_name.#{@content_item.document_type}.overview", count: 1) << ":"
context_inside = true
%>
<% break %>
<% end %>
<% end %>
<%= render 'govuk_publishing_components/components/title',
context: context_string,
context_locale: t_locale_fallback("content_item.schema_name.#{@content_item.document_type}", count: 1),
context_inside: context_inside,
context: t("content_item.schema_name.#{@content_item.document_type}", count: 1) << ":",
context_locale: t_locale_fallback("content_item.schema_name.#{@content_item.document_type}", count: 1) ,
context_inside: true,
title: @content_item.title,
average_title_length: "long"
%>
2 changes: 1 addition & 1 deletion test/integration/fatality_notice_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class FatalityNoticeTest < ActionDispatch::IntegrationTest
setup_and_visit_content_item("withdrawn_fatality_notice")

assert page.has_title?(
"[Withdrawn] Sir George Pomeroy Colley killed in Boer War - Fatality notice - GOV.UK",
"[Withdrawn] Fatality notice: Sir George Pomeroy Colley killed in Boer War - Fatality notice - GOV.UK",
)

within ".gem-c-notice" do
Expand Down
11 changes: 10 additions & 1 deletion test/presenters/content_item/withdrawable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,26 @@ def title
content_item["title"]
end

def schema_name
content_item["schema_name"]
end

def document_type
content_item["document_type"]
end

def content_item
{
"title" => "Proportion of residents who do any walking or cycling (at local authority level) (CW010)",
"withdrawn_notice" => {
"withdrawn_at" => "2016-07-12T09:47:15Z",
},
"document_type" => "statistical_data_set",
}
end
end

assert_equal @withdrawable.page_title, "[Withdrawn] Proportion of residents who do any walking or cycling (at local authority level) (CW010)"
assert_equal @withdrawable.page_title, "[Withdrawn] Statistical data set: Proportion of residents who do any walking or cycling (at local authority level) (CW010)"
end

test "notice title and description are generated correctly" do
Expand Down

0 comments on commit cbc845a

Please sign in to comment.