Browse Source

Use table component for logs list

pull/619/head
Paul Robert Lloyd 3 years ago committed by baarkerlounger
parent
commit
235bce91b4
  1. 104
      app/views/case_logs/_log_list.html.erb

104
app/views/case_logs/_log_list.html.erb

@ -1,58 +1,70 @@
<section class="app-table-group" tabindex="0" aria-labelledby="<%= title.dasherize %>"> <section class="app-table-group" tabindex="0" aria-labelledby="<%= title.dasherize %>">
<table class="govuk-table"> <%= govuk_table do |table| %>
<caption id="<%= title.dasherize %>" class="govuk-!-font-size-19 govuk-!-font-weight-regular"> <%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular], id: title.dasherize) do |caption| %>
<span class="govuk-!-margin-right-4"> <span class="govuk-!-margin-right-4">
<strong><%= pagy.count %></strong> total <%= title.downcase %> <strong><%= pagy.count %></strong> total <%= title.downcase %>
</span> </span>
<%= govuk_link_to "Download (CSV)", "/logs.csv", type: "text/csv" %> <%= govuk_link_to "Download (CSV)", "/logs.csv", type: "text/csv" %>
</caption> <% end %>
<thead class="govuk-table__head"> <%= table.head do |head| %>
<tr class="govuk-table__row"> <%= head.row do |row| %>
<th class="govuk-table__header" scope="col">Log</th> <% row.cell(header: true, text: "Log", html_attributes: {
<th class="govuk-table__header" scope="col">Tenant</th> scope: "col",
<th class="govuk-table__header" scope="col">Property</th> }) %>
<th class="govuk-table__header" scope="col">Tenancy starts</th> <% row.cell(header: true, text: "Tenant", html_attributes: {
<th class="govuk-table__header" scope="col">Log created</th> scope: "col",
<th class="govuk-table__header" scope="col">Status</th> }) %>
<% row.cell(header: true, text: "Property", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Tenancy starts", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Log created", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Log Status", html_attributes: {
scope: "col",
}) %>
<% if current_user.support? %> <% if current_user.support? %>
<th class="govuk-table__header" scope="col">Owning organisation</th> <% row.cell(header: true, text: "Owning organisation", html_attributes: {
<th class="govuk-table__header" scope="col">Managing organisation</th> scope: "col",
}) %>
<% row.cell(header: true, text: "Managing organisation", html_attributes: {
scope: "col",
}) %>
<% end %> <% end %>
</tr> <% end %>
</thead> <% end %>
<tbody class="govuk-table__body"> <%= table.body do |body| %>
<% case_logs.map do |log| %> <% case_logs.map do |log| %>
<tr class="govuk-table__row"> <%= body.row do |row| %>
<th class="govuk-table__header" scope="row"> <% row.cell(header: true, html_attributes: {
<%= govuk_link_to case_log_path(log) do %> scope: "row",
<span class="govuk-visually-hidden">Log </span><%= log.id %> }) do %>
<%= govuk_link_to case_log_path(log) do %>
<span class="govuk-visually-hidden">Log </span><%= log.id %>
<% end %>
<% end %>
<% row.cell(
text: log.tenant_code? ? log.tenant_code : "–",
classes: "app-!-font-tabular",
) %>
<% row.cell(
text: log.propcode? ? log.propcode : "–",
classes: "app-!-font-tabular",
) %>
<% row.cell(text: log.startdate.present? ? log.startdate.to_formatted_s(:govuk_date) : "–") %>
<% row.cell(text: log.created_at.to_formatted_s(:govuk_date)) %>
<% row.cell do %>
<%= status_tag(log.status) %>
<% end %>
<% if current_user.support? %>
<% row.cell(text: log.owning_organisation.name) %>
<% row.cell(text: log.managing_organisation.name) %>
<% end %> <% end %>
</th>
<td class="govuk-table__cell app-!-font-tabular">
<%= log.tenant_code? ? log.tenant_code : "–" %>
</td>
<td class="govuk-table__cell app-!-font-tabular">
<%= log.propcode? ? log.propcode : "–" %>
</td>
<td class="govuk-table__cell">
<%= log.startdate.present? ? log.startdate.to_formatted_s(:govuk_date) : "–" %>
</td>
<td class="govuk-table__cell">
<%= log.created_at.to_formatted_s(:govuk_date) %>
</td>
<td class="govuk-table__cell">
<%= status_tag(log.status) %>
</td>
<% if current_user.support? %>
<td class="govuk-table__cell">
<%= log.owning_organisation.name %>
</td>
<td class="govuk-table__cell">
<%= log.managing_organisation.name %>
</td>
<% end %> <% end %>
</tr>
<% end %> <% end %>
</tbody> <% end %>
</table> <% end %>
</section> </section>

Loading…
Cancel
Save