Browse Source

Refactor name history display into a partial for better code organization

pull/3057/head
Manny Dinssa 2 weeks ago
parent
commit
d72e1a4a9e
  1. 22
      app/views/organisation_name_changes/_name_history_list.html.erb
  2. 23
      app/views/organisation_name_changes/new.html.erb

22
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 %>

23
app/views/organisation_name_changes/new.html.erb

@ -17,28 +17,7 @@
</div>
<div class="govuk-grid-column-three-quarters">
<%= 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" %>
</div>
<div class="govuk-grid-column-two-thirds">

Loading…
Cancel
Save