Browse Source

user table component for organisations table

pull/557/head
Kat 3 years ago
parent
commit
8a2b20418f
  1. 53
      app/views/organisations/_organisation_list.html.erb
  2. 2
      spec/requests/organisations_controller_spec.rb

53
app/views/organisations/_organisation_list.html.erb

@ -1,33 +1,28 @@
<% content_for :title, title %> <% content_for :title, title %>
<section class="app-table-group" tabindex="0" aria-labelledby="<%= title.dasherize %>"> <%= govuk_table do |table| %>
<table id="all-organisations-table" class="govuk-table"> <%= table.caption(size: "s", classes: %w[govuk-!-text-align-left govuk-!-margin-top-4 govuk-!-margin-bottom-4]) do |caption| %>
<caption id="<%= title.dasherize %>" class="govuk-!-text-align-left govuk-!-margin-top-4 govuk-!-margin-bottom-4">
<span class="govuk-!-margin-right-4"> <span class="govuk-!-margin-right-4">
<strong><%= pagy.count %></strong> total <%= title.downcase %> <strong><%= @pagy.count %></strong><span style="font-weight: normal"> total <%= title.downcase %></span>
</span> </span>
</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">Name</th> <% row.cell(header: true, text: "Name") %>
<th class="govuk-table__header" scope="col">Registration number</th> <% row.cell(header: true, text: "Registration number") %>
<th class="govuk-table__header" scope="col">Type</th> <% row.cell(header: true, text: "Type") %>
</tr> <% end %>
</thead> <% end %>
<tbody class="govuk-table__body"> <% @organisations.each do |organisation| %>
<% organisations.map do |organisation| %> <%= table.body do |body| %>
<tr class="govuk-table__row"> <%= body.row do |row| %>
<th class="govuk-table__header" scope="row"> <% row.cell do %>
<%= govuk_link_to organisation.name, "organisations/#{organisation.id}/logs" %> <%= govuk_link_to(organisation.name, "organisations/#{organisation.id}/logs", class: "govuk-!-font-weight-bold") %>
</th> <% end %>
<td class="govuk-table__cell app-!-font-tabular"> <% row.cell(text: organisation.housing_registration_no) %>
<%= organisation.housing_registration_no %> <% row.cell(text: display_provider_type(organisation.provider_type)) %>
</td> <% end %>
<td class="govuk-table__cell app-!-font-tabular"> <% end %>
<%= display_provider_type(organisation.provider_type) %> <% end %>
</td> <% end %>
</tr>
<% end %>
</tbody>
</table>
</section>

2
spec/requests/organisations_controller_spec.rb

@ -419,7 +419,7 @@ RSpec.describe OrganisationsController, type: :request do
end end
it "allows to edit the organisation details" do it "allows to edit the organisation details" do
expect(page).to have_link("Change", count: 10) expect(page).to have_link("Change", count: 3)
end end
end end
end end

Loading…
Cancel
Save