From d72e1a4a9ee8c26257c178cee0779285bb3f5a97 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Thu, 17 Apr 2025 15:48:25 +0100 Subject: [PATCH] Refactor name history display into a partial for better code organization --- .../_name_history_list.html.erb | 22 ++++++++++++++++++ .../organisation_name_changes/new.html.erb | 23 +------------------ 2 files changed, 23 insertions(+), 22 deletions(-) create mode 100644 app/views/organisation_name_changes/_name_history_list.html.erb diff --git a/app/views/organisation_name_changes/_name_history_list.html.erb b/app/views/organisation_name_changes/_name_history_list.html.erb new file mode 100644 index 000000000..9603b6cb0 --- /dev/null +++ b/app/views/organisation_name_changes/_name_history_list.html.erb @@ -0,0 +1,22 @@ +<%= govuk_details(summary_text: "View name history") do %> + <%= govuk_table do |table| %> + <%= table.with_head do |head| %> + <% head.with_row do |row| %> + <% row.with_cell(header: true, text: "Name") %> + <% row.with_cell(header: true, text: "Start Date") %> + <% row.with_cell(header: true, text: "End Date") %> + <% row.with_cell(header: true, text: "Status") %> + <% end %> + <% end %> + <% @previous_name_changes.each do |change| %> + <%= table.with_body do |body| %> + <% body.with_row do |row| %> + <% row.with_cell(text: change[:name]) %> + <% row.with_cell(text: change[:start_date]&.to_formatted_s(:govuk_date)) %> + <% row.with_cell(text: change[:end_date]&.to_formatted_s(:govuk_date) || "None") %> + <% row.with_cell text: status_tag(change[:status].to_sym) %> + <% end %> + <% end %> + <% end %> + <% end %> +<% end %> diff --git a/app/views/organisation_name_changes/new.html.erb b/app/views/organisation_name_changes/new.html.erb index 5537f0a50..075d70eb4 100644 --- a/app/views/organisation_name_changes/new.html.erb +++ b/app/views/organisation_name_changes/new.html.erb @@ -17,28 +17,7 @@
- <%= govuk_details(summary_text: "View name history") do %> - <%= govuk_table do |table| %> - <%= table.with_head do |head| %> - <% head.with_row do |row| %> - <% row.with_cell(header: true, text: "Name") %> - <% row.with_cell(header: true, text: "Start Date") %> - <% row.with_cell(header: true, text: "End Date") %> - <% row.with_cell(header: true, text: "Status") %> - <% end %> - <% end %> - <% @previous_name_changes.each do |change| %> - <%= table.with_body do |body| %> - <% body.with_row do |row| %> - <% row.with_cell(text: change[:name]) %> - <% row.with_cell(text: change[:start_date]&.to_formatted_s(:govuk_date)) %> - <% row.with_cell(text: change[:end_date]&.to_formatted_s(:govuk_date) || "None") %> - <% row.with_cell text: status_tag(change[:status].to_sym) %> - <% end %> - <% end %> - <% end %> - <% end %> - <% end %> + <%= render partial: "organisation_name_changes/name_history_list" %>