From e167e5863deed75f0fa055fb4931b45f0bce1f91 Mon Sep 17 00:00:00 2001 From: JG Date: Thu, 26 May 2022 15:03:47 +0100 Subject: [PATCH] uniform partials --- app/frontend/styles/_table-group.scss | 2 +- .../organisations/_organisation_list.html.erb | 60 ++++++------ app/views/users/_user_list.html.erb | 94 ++++++++++--------- spec/features/log_spec.rb | 4 +- 4 files changed, 82 insertions(+), 78 deletions(-) diff --git a/app/frontend/styles/_table-group.scss b/app/frontend/styles/_table-group.scss index b3e29acb7..c5ca328f3 100644 --- a/app/frontend/styles/_table-group.scss +++ b/app/frontend/styles/_table-group.scss @@ -2,7 +2,7 @@ overflow-x: auto; overflow-y: hidden; margin: govuk-spacing(-3) govuk-spacing(-3) govuk-spacing(3); - padding: govuk-spacing(1) govuk-spacing(3); + padding: govuk-spacing(3) govuk-spacing(3); scrollbar-color: $govuk-text-colour govuk-colour("light-grey"); .govuk-table { diff --git a/app/views/organisations/_organisation_list.html.erb b/app/views/organisations/_organisation_list.html.erb index 78f60685d..20e35b40c 100644 --- a/app/views/organisations/_organisation_list.html.erb +++ b/app/views/organisations/_organisation_list.html.erb @@ -1,35 +1,37 @@ -<%= govuk_table do |table| %> - <%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %> - <% if searched.present? %> - <%= pagy.count %> <%= item_label %> found matching ‘<%= searched %>’ of <%= total_count %> total organisations. <%= govuk_link_to("Clear search", request.path) %> - <% else %> - <%= pagy.count %> total organisations. +
+ <%= govuk_table do |table| %> + <%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %> + <% if searched.present? %> + <%= pagy.count %> <%= item_label %> found matching ‘<%= searched %>’ of <%= total_count %> total organisations. <%= govuk_link_to("Clear search", request.path) %> + <% else %> + <%= pagy.count %> total organisations. + <% end %> <% end %> - <% end %> - <%= table.head do |head| %> - <%= head.row do |row| %> - <% 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", - }) %> + <%= table.head do |head| %> + <%= head.row do |row| %> + <% 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 %> - <% end %> - <% @organisations.each do |organisation| %> - <%= table.body do |body| %> - <%= body.row do |row| %> - <% row.cell(header: true, html_attributes: { - scope: "row", - }) do %> - <%= govuk_link_to(organisation.name, "organisations/#{organisation.id}/logs") %> + <% @organisations.each do |organisation| %> + <%= table.body do |body| %> + <%= body.row do |row| %> + <% 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: organisation.display_provider_type) %> <% end %> - <% row.cell(text: organisation.housing_registration_no) %> - <% row.cell(text: organisation.display_provider_type) %> <% end %> <% end %> <% end %> -<% end %> +
diff --git a/app/views/users/_user_list.html.erb b/app/views/users/_user_list.html.erb index a934e211e..171e21220 100644 --- a/app/views/users/_user_list.html.erb +++ b/app/views/users/_user_list.html.erb @@ -1,54 +1,56 @@ -<%= govuk_table do |table| %> - <%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %> - - <% if searched.present? %> - <%= pagy.count %> <%= item_label %> found matching ‘<%= searched %>’ of <%= total_count %> total users. <%= govuk_link_to("Clear search", request.path) %> - <% else %> - <%= pagy.count %> total users. +
+ <%= govuk_table do |table| %> + <%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %> + + <% if searched.present? %> + <%= pagy.count %> <%= item_label %> found matching ‘<%= searched %>’ of <%= total_count %> total users. <%= govuk_link_to("Clear search", request.path) %> + <% else %> + <%= pagy.count %> total users. + <% end %> + + <% if current_user.support? %> + <% query = searched.present? ? "?search=#{searched}" : nil %> + <%= govuk_link_to "Download (CSV)", "/users.csv#{query}", type: "text/csv" %> <% end %> - - <% if current_user.support? %> - <% query = searched.present? ? "?search=#{searched}" : nil %> - <%= govuk_link_to "Download (CSV)", "/users.csv#{query}", type: "text/csv" %> <% end %> - <% end %> - <%= table.head do |head| %> - <%= head.row do |row| %> - <% 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", - }) %> + <%= table.head do |head| %> + <%= head.row do |row| %> + <% 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 %> - <% end %> - <% users.each do |user| %> - <%= table.body do |body| %> - <%= body.row do |row| %> - <% 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? %> -
+ <% users.each do |user| %> + <%= table.body do |body| %> + <%= body.row do |row| %> + <% 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? %> +
+ <% end %> + <%= user.is_data_protection_officer? ? govuk_tag( + classes: "app-tag--small", + colour: "turquoise", + text: "Data protection officer", + ) : "" %> + <%= user.is_key_contact? ? govuk_tag( + classes: "app-tag--small", + colour: "turquoise", + text: "Key contact", + ) : "" %> <% end %> - <%= user.is_data_protection_officer? ? govuk_tag( - classes: "app-tag--small", - colour: "turquoise", - text: "Data protection officer", - ) : "" %> - <%= user.is_key_contact? ? govuk_tag( - classes: "app-tag--small", - colour: "turquoise", - text: "Key contact", - ) : "" %> + <% row.cell(text: simple_format(org_cell(user), {}, wrapper_tag: "div")) %> + <% row.cell(text: user.last_sign_in_at&.to_formatted_s(:govuk_date)) %> <% end %> - <% row.cell(text: simple_format(org_cell(user), {}, wrapper_tag: "div")) %> - <% row.cell(text: user.last_sign_in_at&.to_formatted_s(:govuk_date)) %> <% end %> <% end %> <% end %> -<% end %> +
diff --git a/spec/features/log_spec.rb b/spec/features/log_spec.rb index 0fdecb003..4a6140f47 100644 --- a/spec/features/log_spec.rb +++ b/spec/features/log_spec.rb @@ -17,13 +17,13 @@ RSpec.describe "Log Features" do context "when I search for a specific log" do it "there is a search bar with a message and search button for logs" do - expect(page).to have_field("search-field") + expect(page).to have_field("search") expect(page).to have_content("Search by log ID, tenant code, property reference or postcode") expect(page).to have_button("Search") end it "displays log matching the log ID" do - fill_in("search-field", with: log_to_search.id) + fill_in("search", with: log_to_search.id) click_button("Search") expect(page).to have_content(log_to_search.id) expect(page).not_to have_content(same_organisation_log.id)