Skip to content

Commit 8d32bda

Browse files
authored
Merge pull request #72 from alphagov/CM-330-carry-out-content-review-changes-in-the-code
(CM-330) Carry out content review changes in the code
2 parents 4d7c7a6 + 1267426 commit 8d32bda

30 files changed

Lines changed: 168 additions & 77 deletions

app/components/document/show/embedded_objects/blocks_component.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<%= tag.div(class: component_classes) do %>
22
<div class="app-c-embedded-objects-blocks-component__main-summary-card-wrapper">
33
<%= render "govuk_publishing_components/components/summary_card", {
4-
title: "Content blocks",
4+
title:,
55
rows: summary_card_rows,
66
} %>
77
</div>

app/components/document/show/embedded_objects/blocks_component.rb

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,24 @@ def attribute_rows(key_name = :key)
3939
end
4040
end
4141

42+
def block_title(key)
43+
I18n.t("edition.titles.#{document.schema.block_type}.#{schema.block_type}.#{key}", default: key.humanize.capitalize)
44+
end
45+
4246
def nested_blocks
4347
blocks = []
4448

4549
nested_items(items).each do |key, items|
4650
if items.is_a?(Array)
4751
items.each_with_index do |nested_items, index|
4852
blocks << {
49-
title: "#{key.singularize.titleize} #{index + 1}",
53+
title: "#{block_title(key.singularize)} #{index + 1}",
5054
rows: rows_for_nested_items(nested_items, key, index),
5155
}
5256
end
5357
else
5458
blocks << {
55-
title: key.titleize,
59+
title: block_title(key),
5660
rows: rows_for_nested_items(items, key, nil),
5761
}
5862
end
@@ -64,8 +68,8 @@ def nested_blocks
6468
def rows_for_nested_items(items, nested_name, index)
6569
items.map do |key, value|
6670
{
67-
key: key_to_title(key, schema_name),
68-
value: content_for_row(embed_code_identifier(nested_name, index, key), value),
71+
key: key_to_title(key, schema_name, "#{object_type}.#{nested_name}"),
72+
value: content_for_row(embed_code_identifier(nested_name, index, key), translated_value(key, value)),
6973
data: data_attributes_for_row(embed_code_identifier(nested_name, index, key)),
7074
}
7175
end
@@ -75,9 +79,13 @@ def object_name
7579
object_type.singularize.humanize.downcase
7680
end
7781

82+
def title
83+
"#{object_name} block".capitalize
84+
end
85+
7886
def block_row
7987
{
80-
key: object_type.singularize.titleize,
88+
key: object_type.humanize.singularize.capitalize,
8189
value: content_for_block_row,
8290
data: data_attributes_for_block_row,
8391
}

app/components/document/show/embedded_objects/subschema_items_component.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def id
1010
end
1111

1212
def label
13-
"#{subschema.name.pluralize} (#{embedded_objects.count})"
13+
"#{subschema.name.singularize.capitalize} (#{embedded_objects.count})"
1414
end
1515

1616
private

app/components/edition/details/fields/array_component.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="app-c-content-block-manager-array-component" data-ga4-section="<%= label %>">
22
<%= render "govuk_publishing_components/components/add_another", {
33
fieldset_legend: label,
4-
add_button_text: "Add another #{label}",
4+
add_button_text: I18n.t("buttons.add_another", item: label.downcase),
55
items:,
66
empty:,
77
data_attributes: {

app/components/edition/host_content/table_component.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class Edition::HostContent::TableComponent < Document::Show::HostEditionsTableCo
22
private
33

44
def head
5-
[super, { text: "Preview (Opens in new tab)" }].flatten
5+
[super, { text: "Preview (opens in new tab)" }].flatten
66
end
77

88
def row_for_content_item(content_item)

app/components/edition/workflow/group_component.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def tab_for_subschema(subschema)
2626
end
2727

2828
def tab_label(subschema, items)
29-
"#{subschema.name.titleize} (#{items.values.count})"
29+
"#{subschema.name.singularize.capitalize} (#{items.values.count})"
3030
end
3131

3232
def content_for_tab(subschema, items)

app/components/shared/embedded_objects/summary_card/nested_item_component.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def title
3131
def rows
3232
nested_items.map do |field_name, value|
3333
{
34-
key: humanized_label(schema_name: root_schema_name, relative_key: field_name, root_object: object_type),
34+
key: humanized_label(schema_name: root_schema_name, relative_key: field_name, root_object: "#{object_type}.#{object_key}"),
3535
value: render_govspeak_if_enabled_for_field(
3636
object_key: object_key,
3737
field_name: field_name,

app/components/shared/embedded_objects/summary_card_component.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
items,
2222
object_key: key,
2323
object_type:,
24-
title: key.singularize.titleize,
24+
title: nested_item_title(key),
2525
subschema: schema,
2626
root_schema_name: root_schema.block_type,
2727
) %>
@@ -30,7 +30,7 @@
3030
nested_items: items,
3131
object_key: key,
3232
object_type:,
33-
title: key.singularize.titleize,
33+
title: nested_item_title(key),
3434
subschema: schema,
3535
root_schema_name: root_schema.block_type,
3636
) %>

app/components/shared/embedded_objects/summary_card_component.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ def initialize(edition:, object_type:, object_title:, redirect_url: nil, test_id
2121
attr_reader :edition, :object_type, :object_title, :redirect_url, :test_id_prefix
2222

2323
def title
24-
"#{object_type.titleize.singularize} details"
24+
"#{object_type.titleize.singularize.capitalize} details"
25+
end
26+
27+
def nested_item_title(key)
28+
I18n.t("edition.titles.#{edition.schema.block_type}.#{schema.id}.#{key}", default: key.singularize.titleize)
2529
end
2630

2731
def items

app/components/shared/embedded_objects_component.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ def show_title?
3030
end
3131

3232
def add_button_text
33-
has_embedded_objects? ? "Add another #{subschema_name}" : "Add #{helpers.add_indefinite_article subschema_name}"
33+
if has_embedded_objects?
34+
I18n.t("buttons.add_another", item: subschema_name)
35+
else
36+
I18n.t("buttons.add", item: helpers.add_indefinite_article(subschema_name))
37+
end
3438
end
3539

3640
def has_embedded_objects?

0 commit comments

Comments
 (0)