Browse Source

Correct markup for user and organisation tables

pull/619/head
Paul Robert Lloyd 3 years ago committed by baarkerlounger
parent
commit
97fb7439f2
  1. 4
      app/helpers/tab_nav_helper.rb
  2. 18
      app/views/organisations/_organisation_list.html.erb
  3. 16
      app/views/users/index.html.erb
  4. 4
      spec/helpers/tab_nav_helper_spec.rb

4
app/helpers/tab_nav_helper.rb

@ -3,11 +3,11 @@ module TabNavHelper
def user_cell(user)
link_text = user.name.presence || user.email
[govuk_link_to(link_text, user, class: "govuk-!-font-weight-bold"), user.email].join("\n")
[govuk_link_to(link_text, user), "<span class=\"govuk-!-font-weight-regular app-!-colour-muted\">#{user.email}</span>"].join("\n")
end
def org_cell(user)
role = "<span class='app-!-colour-muted'>#{user.role.to_s.humanize}</span>"
role = "<span class=\"app-!-colour-muted\">#{user.role.to_s.humanize}</span>"
[user.organisation.name, role].join("\n")
end

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

@ -6,16 +6,24 @@
<% end %>
<%= table.head do |head| %>
<%= head.row do |row| %>
<% row.cell(header: true, text: "Name") %>
<% row.cell(header: true, text: "Registration number") %>
<% row.cell(header: true, text: "Type") %>
<% row.cell(header: true, text: "Name", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Registration number", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Type", html_attributes: {
scope: "col",
}) %>
<% end %>
<% end %>
<% @organisations.each do |organisation| %>
<%= table.body do |body| %>
<%= body.row do |row| %>
<% row.cell do %>
<%= govuk_link_to(organisation.name, "organisations/#{organisation.id}/logs", class: "govuk-!-font-weight-bold") %>
<% row.cell(header: true, html_attributes: {
scope: "row",
}) do %>
<%= govuk_link_to(organisation.name, "organisations/#{organisation.id}/logs") %>
<% end %>
<% row.cell(text: organisation.housing_registration_no) %>
<% row.cell(text: display_provider_type(organisation.provider_type)) %>

16
app/views/users/index.html.erb

@ -25,15 +25,23 @@
<% end %>
<%= table.head do |head| %>
<%= head.row do |row| %>
<% row.cell(header: true, text: "Name and email adress") %>
<% row.cell(header: true, text: "Organisation and role") %>
<% row.cell(header: true, text: "Last logged in") %>
<% row.cell(header: true, text: "Name and email adress", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Organisation and role", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Last logged in", html_attributes: {
scope: "col",
}) %>
<% end %>
<% end %>
<% @users.each do |user| %>
<%= table.body do |body| %>
<%= body.row do |row| %>
<% row.cell do %>
<% row.cell(header: true, html_attributes: {
scope: "row",
}) do %>
<%= simple_format(user_cell(user), {}, wrapper_tag: "span") %>
<% if user.is_data_protection_officer? || user.is_key_contact? %>
<br>

4
spec/helpers/tab_nav_helper_spec.rb

@ -6,14 +6,14 @@ RSpec.describe TabNavHelper do
describe "#user_cell" do
it "returns user link and email separated by a newline character" do
expected_html = "<a class=\"govuk-link govuk-!-font-weight-bold\" href=\"/users\">Danny Rojas</a>\n#{user.email}"
expected_html = "<a class=\"govuk-link\" href=\"/users\">Danny Rojas</a>\n<span class=\"govuk-!-font-weight-regular app-!-colour-muted\">#{user.email}</span>"
expect(user_cell(user)).to match(expected_html)
end
end
describe "#org_cell" do
it "returns the users org name and role separated by a newline character" do
expected_html = "DLUHC\n<span class='app-!-colour-muted'>Data provider</span>"
expected_html = "DLUHC\n<span class=\"app-!-colour-muted\">Data provider</span>"
expect(org_cell(user)).to match(expected_html)
end
end

Loading…
Cancel
Save