Skip to content

Commit 44bf1b4

Browse files
Use image_usage.title in frontend
Consistently use `image_usage.title` when necessary and remove logic that previously was present in the frontend to calculate the correct title of an image usage.
1 parent 8a7aa4b commit 44bf1b4

10 files changed

Lines changed: 7 additions & 12 deletions

File tree

app/components/admin/edition_images/image_card_component.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<%= render "govuk_publishing_components/components/summary_card", {
22
id: "uploaded_#{image_usage.key}_image_card",
3-
title: image_usage.label&.titleize || image_usage.key.titleize,
43
summary_card_actions: summary_card_actions,
4+
title: image_usage.title.upcase_first,
55
rows: [
66
{
77
key: "Image",

app/components/admin/edition_images/image_upload_component.html.erb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<%
22
image_kind = image_usage.kinds.first
3+
image_usage_title = image_usage.title.downcase
34

4-
hint_text = ["A #{image_kind.display_name} image must be at least <strong>#{image_kind.valid_width}x#{image_kind.valid_height}</strong>."]
5+
hint_text = ["#{image_usage_title.articleize.upcase_first} must be at least <strong>#{image_kind.valid_width}x#{image_kind.valid_height}</strong>."]
56
unless image_usage.multiple
6-
hint_text << " If you are uploading more than one image, <a class=\"govuk-link\" href=\"https://www.gov.uk/guidance/how-to-publish-on-gov-uk/images-and-videos\">read the image guidance</a> on using unique file names."
7+
hint_text << " If you are uploading more than one #{image_usage_title}, <a class=\"govuk-link\" href=\"https://www.gov.uk/guidance/how-to-publish-on-gov-uk/images-and-videos\">read the image guidance</a> on using unique file names."
78
end
89
%>
910

app/components/admin/edition_images/lead_image_card_component.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<%= render "govuk_publishing_components/components/summary_card", {
88
id: "uploaded_#{image_usage.key}_image_card",
9-
title: image_usage.label&.titleize || image_usage.key.titleize,
9+
title: image_usage.title.upcase_first,
1010
summary_card_actions: summary_card_actions,
1111
rows: [
1212
{

app/models/configurable_document_types/case_study.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@
9999
"caption_enabled": true
100100
},
101101
"lead": {
102-
"label": "lead",
103102
"kinds": ["default"],
104103
"multiple": false,
105104
"caption_enabled": true

app/models/configurable_document_types/government_response.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115
"caption_enabled": true
116116
},
117117
"lead": {
118-
"label": "lead",
119118
"kinds": ["default"],
120119
"multiple": false,
121120
"caption_enabled": true

app/models/configurable_document_types/news_story.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115
"caption_enabled": true
116116
},
117117
"lead": {
118-
"label": "lead",
119118
"kinds": ["default"],
120119
"multiple": false,
121120
"caption_enabled": true

app/models/configurable_document_types/press_release.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115
"caption_enabled": true
116116
},
117117
"lead": {
118-
"label": "lead",
119118
"kinds": ["default"],
120119
"multiple": false,
121120
"caption_enabled": true

app/models/configurable_document_types/topical_event.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@
181181
"enabled": true,
182182
"usages": {
183183
"header": {
184-
"label": "header image",
185184
"kinds": ["topical_event_header"],
186185
"multiple": false,
187186
"caption_enabled": true

app/models/configurable_document_types/world_news_story.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100
"caption_enabled": true
101101
},
102102
"lead": {
103-
"label": "lead",
104103
"kinds": ["default"],
105104
"multiple": false,
106105
"caption_enabled": true

app/views/admin/edition_images/new.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<% content_for :context, "#{@edition.title}" %>
2-
<% content_for :page_title, "New #{@image_usage.label} image for #{@edition.format_name}" %>
3-
<% content_for :title, "New #{@image_usage.label} image for #{@edition.format_name}" %>
2+
<% content_for :page_title, "New #{@image_usage.title} for #{@edition.format_name}" %>
3+
<% content_for :title, "New #{@image_usage.title} for #{@edition.format_name}" %>
44
<% content_for :error_summary, render(Admin::ErrorSummaryComponent.new(object: @images.flat_map { |image| image&.errors&.errors }, parent_class: "edition_images")) if @images.present? %>
55

66
<div class="govuk-grid-row">

0 commit comments

Comments
 (0)