diff --git a/app/components/finder_metadata_summary_card_component.html.erb b/app/components/finder_metadata_summary_card_component.html.erb new file mode 100644 index 000000000..9ba690b5d --- /dev/null +++ b/app/components/finder_metadata_summary_card_component.html.erb @@ -0,0 +1,6 @@ +<%= render "govuk_publishing_components/components/summary_card", { + title: "Finder details", + rows: render_finder_summary_rows, + summary_card_actions: @summary_card_actions, + margin_top: 6, +} %> diff --git a/app/components/finder_metadata_summary_card_component.rb b/app/components/finder_metadata_summary_card_component.rb new file mode 100644 index 000000000..def8bc035 --- /dev/null +++ b/app/components/finder_metadata_summary_card_component.rb @@ -0,0 +1,62 @@ +class FinderMetadataSummaryCardComponent < ViewComponent::Base + def initialize(schema, previous_schema: nil, summary_card_actions: []) + @schema = schema + @previous_schema = previous_schema + @summary_card_actions = summary_card_actions + end + + def render_finder_summary_rows + [ + ({ + key: "Title of the finder", + value: @schema.name + } if @previous_schema.nil? || @schema.name != @previous_schema.name), + ({ + key: "Slug or URL", + value: @schema.base_path + } if @previous_schema.nil? || @schema.base_path != @previous_schema.base_path), + ({ + key: "Organisations the finder should be attached to", + value: (@schema.organisations || []).map { |content_id| helpers.organisation_name(content_id) }.compact.join(",") + } if @previous_schema.nil? || @schema.organisations != @previous_schema.organisations), + ({ + key: "Short description (For search engines)", + value: @schema.description + } if @previous_schema.nil? || @schema.description != @previous_schema.description), + ({ + key: "Summary of the finder (Longer description shown below title)", + value: sanitize("
#{@schema.summary}
") + } if @previous_schema.nil? || @schema.summary != @previous_schema.summary), + ({ + key: "Any related links on GOV.UK?", + value: related_links_value, + } if @previous_schema.nil? || @schema.related != @previous_schema.related), + ({ + key: "Should summary of each content show under the title in the finder list page?", + value: @schema.show_summaries ? "Yes" : "No" + } if @previous_schema.nil? || @schema.show_summaries != @previous_schema.show_summaries), + ({ + key: "The document noun (How the documents on the finder are referred to)", + value: (@schema.document_noun || "").humanize + } if @previous_schema.nil? || @schema.document_noun != @previous_schema.document_noun), + ({ + key: "Would you like to set up email alerts for the finder?", + value: @schema.signup_content_id.present? ? "Yes" : "No" + } if @previous_schema.nil? || (@schema.signup_content_id.present? != @previous_schema.signup_content_id.present?)) + ].compact + end + +private + + def related_links_value + if @schema.related + related_links_content = "Yes" + @schema.related.each_with_index do |content_id, index| + related_links_content << sanitize("

Link #{index + 1}: #{content_id}

") + end + related_links_content + else + "No" + end + end +end \ No newline at end of file diff --git a/app/views/admin/confirm_metadata.html.erb b/app/views/admin/confirm_metadata.html.erb index 8abd489b0..6ea4be8b8 100644 --- a/app/views/admin/confirm_metadata.html.erb +++ b/app/views/admin/confirm_metadata.html.erb @@ -28,10 +28,7 @@
- <%= render "metadata_summary_card", { - schema: @proposed_schema, - previous_schema: @current_format.finder_schema, - } %> + <%= render FinderMetadataSummaryCardComponent.new(current_format.finder_schema,previous_schema: @current_format.finder_schema) %>

By submitting you are confirming that these changes are required to the specialist finder. diff --git a/app/views/admin/summary.erb b/app/views/admin/summary.erb index c62001c34..afc32f588 100644 --- a/app/views/admin/summary.erb +++ b/app/views/admin/summary.erb @@ -19,8 +19,7 @@

- <%= render "govuk_publishing_components/components/inset_text", { - } do %> + <%= render "govuk_publishing_components/components/inset_text", {} do %> <%= link_to("View on website (opens in new tab)", current_format.live_url, class: "govuk-link", target: "_blank", rel: "noopener") %> <% end %> @@ -38,7 +37,6 @@ }, ] } %> -
@@ -58,14 +56,11 @@ If you expect multiple changes over a period of time, it will be much more efficient to group these in one request.

- <%= render "metadata_summary_card", { - schema: current_format.finder_schema, - summary_card_actions: [ - { - label: "Request changes", - href: "/admin/metadata/#{current_format.admin_slug}" - }, - ], - } %> + <%= render FinderMetadataSummaryCardComponent.new(current_format.finder_schema, + summary_card_actions: [{ + label: "Request changes", + href: "/admin/metadata/#{current_format.admin_slug}" + }]) + %>