From b87c5b738c0eeb764e635011c205209129ecbe27 Mon Sep 17 00:00:00 2001 From: Daniel Dye Date: Fri, 26 Apr 2024 13:25:19 +0100 Subject: [PATCH] Create app_table helper to extend govuk_table helper The `app_table` helper wraps a `govuk_table` in a `div` with the `overflow-auto` class. This makes the table responsive and viewable across all screen sizes. --- app/helpers/table_helper.rb | 7 +++ app/views/claims/pages/cookies.html.erb | 4 +- .../claims/schools/_grant_conditions.html.erb | 2 +- .../claims/schools/claims/index.html.erb | 52 +++++++++---------- .../claims/schools/mentors/index.html.erb | 2 +- app/views/claims/schools/users/index.html.erb | 2 +- .../support/schools/claims/index.html.erb | 2 +- .../support/schools/mentors/index.html.erb | 2 +- .../support/support_users/index.html.erb | 2 +- .../organisations/users/_list.html.erb | 2 +- .../providers/partner_schools/index.html.erb | 2 +- .../placements/schools/mentors/index.html.erb | 2 +- .../schools/partner_providers/index.html.erb | 2 +- .../schools/placements/index.html.erb | 2 +- .../support/providers/users/index.html.erb | 2 +- .../support/schools/mentors/index.html.erb | 2 +- .../support/schools/placements/index.html.erb | 2 +- .../support/schools/users/index.html.erb | 2 +- .../support/support_users/index.html.erb | 2 +- 19 files changed, 50 insertions(+), 45 deletions(-) create mode 100644 app/helpers/table_helper.rb diff --git a/app/helpers/table_helper.rb b/app/helpers/table_helper.rb new file mode 100644 index 000000000..de0a13be7 --- /dev/null +++ b/app/helpers/table_helper.rb @@ -0,0 +1,7 @@ +module TableHelper + def app_table(*args, **kwargs, &block) + content_tag(:div, class: "overflow-auto") do + govuk_table(*args, **kwargs, &block) + end + end +end diff --git a/app/views/claims/pages/cookies.html.erb b/app/views/claims/pages/cookies.html.erb index 3972e4d2b..28060aaf3 100644 --- a/app/views/claims/pages/cookies.html.erb +++ b/app/views/claims/pages/cookies.html.erb @@ -21,7 +21,7 @@ Essential cookies keep your information secure while you use Claim funding for mentor training. We do not need to ask permission to use them.

- <%= govuk_table do |table| %> + <%= app_table do |table| %> <% table.with_head do |head| %> <% head.with_row do |row| %> <% row.with_cell(header: true, text: "Name") %> @@ -66,7 +66,7 @@
  • what you click on while you’re visiting the site
  • - <%= govuk_table do |table| %> + <%= app_table do |table| %> <% table.with_head do |head| %> <% head.with_row do |row| %> <% row.with_cell(header: true, text: "Name") %> diff --git a/app/views/claims/schools/_grant_conditions.html.erb b/app/views/claims/schools/_grant_conditions.html.erb index 1ac11bb66..39efee447 100644 --- a/app/views/claims/schools/_grant_conditions.html.erb +++ b/app/views/claims/schools/_grant_conditions.html.erb @@ -113,7 +113,7 @@

    For each mentor that completes the full 20 hours of training, the table below sets out how much a school can claim.

    If a mentor undertakes fewer than 20 hours of training, the funding is calculated per hour. For example, if a mentor in a school outside London completed 10 hours of training, the school can claim £438. This is calculated at £43.80 (per hour) x 10 (hours of training).

    - <%= govuk_table do |table| %> + <%= app_table do |table| %> <% table.with_head do |head| %> <% head.with_row do |row| %> <% row.with_cell(header: true, text: "Funding available per mentor") %> diff --git a/app/views/claims/schools/claims/index.html.erb b/app/views/claims/schools/claims/index.html.erb index 42e803ae8..5433a2f2a 100644 --- a/app/views/claims/schools/claims/index.html.erb +++ b/app/views/claims/schools/claims/index.html.erb @@ -15,39 +15,37 @@ <% end %> <% if @claims.any? %> -
    - <%= govuk_table do |table| %> - <% table.with_head do |head| %> - <% head.with_row do |row| %> - <% row.with_cell(header: true, text: Claims::Claim.human_attribute_name(:reference)) %> - <% row.with_cell(header: true, text: Claims::Claim.human_attribute_name(:accredited_provider)) %> - <% row.with_cell(header: true, text: Claims::Claim.human_attribute_name(:mentors)) %> - <% row.with_cell(header: true, text: Claims::Claim.human_attribute_name(:claim_amount)) %> - <% row.with_cell(header: true, text: Claims::Claim.human_attribute_name(:submitted_at)) %> - <% row.with_cell(header: true, text: Claims::Claim.human_attribute_name(:status)) %> - <% end %> + <%= app_table do |table| %> + <% table.with_head do |head| %> + <% head.with_row do |row| %> + <% row.with_cell(header: true, text: Claims::Claim.human_attribute_name(:reference)) %> + <% row.with_cell(header: true, text: Claims::Claim.human_attribute_name(:accredited_provider)) %> + <% row.with_cell(header: true, text: Claims::Claim.human_attribute_name(:mentors)) %> + <% row.with_cell(header: true, text: Claims::Claim.human_attribute_name(:claim_amount)) %> + <% row.with_cell(header: true, text: Claims::Claim.human_attribute_name(:submitted_at)) %> + <% row.with_cell(header: true, text: Claims::Claim.human_attribute_name(:status)) %> <% end %> + <% end %> - <% table.with_body do |body| %> - <% @claims.each do |claim| %> - <% body.with_row do |row| %> - <% row.with_cell(text: govuk_link_to(claim.reference, claims_school_claim_path(id: claim.id))) %> - <% row.with_cell(text: claim.provider_name) %> - <% row.with_cell do %> - - <% end %> - <% row.with_cell(text: humanized_money_with_symbol(claim.amount)) %> - <% row.with_cell(text: safe_l(claim.submitted_on, format: :short)) %> - <% row.with_cell(text: render(Claim::StatusTagComponent.new(claim:))) %> + <% table.with_body do |body| %> + <% @claims.each do |claim| %> + <% body.with_row do |row| %> + <% row.with_cell(text: govuk_link_to(claim.reference, claims_school_claim_path(id: claim.id))) %> + <% row.with_cell(text: claim.provider_name) %> + <% row.with_cell do %> + <% end %> + <% row.with_cell(text: humanized_money_with_symbol(claim.amount)) %> + <% row.with_cell(text: safe_l(claim.submitted_on, format: :short)) %> + <% row.with_cell(text: render(Claim::StatusTagComponent.new(claim:))) %> <% end %> <% end %> <% end %> -
    + <% end %> <%= render PaginationComponent.new(pagy: @pagy) %> <% else %> diff --git a/app/views/claims/schools/mentors/index.html.erb b/app/views/claims/schools/mentors/index.html.erb index c6c0ddd3a..114d5b539 100644 --- a/app/views/claims/schools/mentors/index.html.erb +++ b/app/views/claims/schools/mentors/index.html.erb @@ -9,7 +9,7 @@ <%= govuk_button_to(t(".add_mentor"), new_claims_school_mentor_path, method: :get) %> <% if @mentors.any? %> - <%= govuk_table do |table| %> + <%= app_table do |table| %> <% table.with_head do |head| %> <% head.with_row do |row| %> <% row.with_cell(header: true, text: Mentor.human_attribute_name(:name)) %> diff --git a/app/views/claims/schools/users/index.html.erb b/app/views/claims/schools/users/index.html.erb index 05b545dd2..a43a792cd 100644 --- a/app/views/claims/schools/users/index.html.erb +++ b/app/views/claims/schools/users/index.html.erb @@ -6,7 +6,7 @@
    <%= govuk_button_to(t(".add_user"), new_claims_school_user_path, method: :get) %> <% if @users.any? %> - <%= govuk_table do |table| %> + <%= app_table do |table| %> <% table.with_head do |head| %> <% head.with_row do |row| %> <% row.with_cell(header: true, text: User.human_attribute_name("full_name")) %> diff --git a/app/views/claims/support/schools/claims/index.html.erb b/app/views/claims/support/schools/claims/index.html.erb index fe03b50d9..037a3aee8 100644 --- a/app/views/claims/support/schools/claims/index.html.erb +++ b/app/views/claims/support/schools/claims/index.html.erb @@ -14,7 +14,7 @@ <% end %> <% if @claims.any? %> - <%= govuk_table do |table| %> + <%= app_table do |table| %> <% table.with_head do |head| %> <% head.with_row do |row| %> <% row.with_cell(header: true, text: Claims::Claim.human_attribute_name(:reference)) %> diff --git a/app/views/claims/support/schools/mentors/index.html.erb b/app/views/claims/support/schools/mentors/index.html.erb index e1e168e79..6313f342f 100644 --- a/app/views/claims/support/schools/mentors/index.html.erb +++ b/app/views/claims/support/schools/mentors/index.html.erb @@ -14,7 +14,7 @@ <%= govuk_button_to(t(".add_mentor"), new_claims_support_school_mentor_path, method: :get) %> <% if @mentors.any? %> - <%= govuk_table do |table| %> + <%= app_table do |table| %> <% table.with_head do |head| %> <% head.with_row do |row| %> <% row.with_cell(header: true, text: Mentor.human_attribute_name(:name)) %> diff --git a/app/views/claims/support/support_users/index.html.erb b/app/views/claims/support/support_users/index.html.erb index 468da1fdd..b2a22293b 100644 --- a/app/views/claims/support/support_users/index.html.erb +++ b/app/views/claims/support/support_users/index.html.erb @@ -9,7 +9,7 @@
    <% if @support_users.any? %> - <%= govuk_table do |table| %> + <%= app_table do |table| %> <% table.with_head do |head| %> <% head.with_row do |row| %> <% row.with_cell(text: User.human_attribute_name(:name), width: "govuk-!-width-one-third") %> diff --git a/app/views/placements/organisations/users/_list.html.erb b/app/views/placements/organisations/users/_list.html.erb index 81e2483b8..6d2761408 100644 --- a/app/views/placements/organisations/users/_list.html.erb +++ b/app/views/placements/organisations/users/_list.html.erb @@ -1,5 +1,5 @@ <% if users.any? %> - <%= govuk_table do |table| %> + <%= app_table do |table| %> <% table.with_head do |head| %> <% head.with_row do |row| %> <% row.with_cell(header: true, text: t(".name")) %> diff --git a/app/views/placements/providers/partner_schools/index.html.erb b/app/views/placements/providers/partner_schools/index.html.erb index 6d2eb57b3..0e832ff99 100644 --- a/app/views/placements/providers/partner_schools/index.html.erb +++ b/app/views/placements/providers/partner_schools/index.html.erb @@ -7,7 +7,7 @@
    <%= govuk_button_to(t(".add_partner_school"), new_placements_provider_partner_school_path, method: :get) %> <% if @partner_schools.any? %> - <%= govuk_table do |table| %> + <%= app_table do |table| %> <% table.with_head do |head| %> <% head.with_row do |row| %> <% row.with_cell(header: true, text: t(".attributes.partner_schools.name")) %> diff --git a/app/views/placements/schools/mentors/index.html.erb b/app/views/placements/schools/mentors/index.html.erb index 3c5f7b7bb..45ce131fc 100644 --- a/app/views/placements/schools/mentors/index.html.erb +++ b/app/views/placements/schools/mentors/index.html.erb @@ -10,7 +10,7 @@ <%= govuk_button_to(t(".add_mentor"), new_placements_school_mentor_path, method: :get) %> <% if @mentors.any? %> - <%= govuk_table do |table| %> + <%= app_table do |table| %> <% table.with_head do |head| %> <% head.with_row do |row| %> <% row.with_cell(header: true, text: Mentor.human_attribute_name(:name)) %> diff --git a/app/views/placements/schools/partner_providers/index.html.erb b/app/views/placements/schools/partner_providers/index.html.erb index 6bc864b59..a7af5704b 100644 --- a/app/views/placements/schools/partner_providers/index.html.erb +++ b/app/views/placements/schools/partner_providers/index.html.erb @@ -7,7 +7,7 @@
    <%= govuk_button_to(t(".add_partner_provider"), new_placements_school_partner_provider_path, method: :get) %> <% if @partner_providers.any? %> - <%= govuk_table do |table| %> + <%= app_table do |table| %> <% table.with_head do |head| %> <% head.with_row do |row| %> <% row.with_cell(header: true, text: t(".attributes.partner_providers.name")) %> diff --git a/app/views/placements/schools/placements/index.html.erb b/app/views/placements/schools/placements/index.html.erb index 2c14f0c92..8302a0f91 100644 --- a/app/views/placements/schools/placements/index.html.erb +++ b/app/views/placements/schools/placements/index.html.erb @@ -7,7 +7,7 @@ <%= govuk_button_to(t(".add_placement"), new_placements_school_placement_build_path(@school, placement_id: "new_placement"), method: :get) %> <% if @placements.any? %> - <%= govuk_table do |table| %> + <%= app_table do |table| %> <% table.with_head do |head| %> <% head.with_row do |row| %> <% row.with_cell(header: true, text: t(".subject")) %> diff --git a/app/views/placements/support/providers/users/index.html.erb b/app/views/placements/support/providers/users/index.html.erb index a8c9bb9f8..3a55342c3 100644 --- a/app/views/placements/support/providers/users/index.html.erb +++ b/app/views/placements/support/providers/users/index.html.erb @@ -13,7 +13,7 @@ <%= govuk_button_to(t(".add_user"), new_placements_support_provider_user_path(@provider), method: :get) %> <% if @users.any? %> - <%= govuk_table do |table| %> + <%= app_table do |table| %> <% table.with_head do |head| %> <% head.with_row do |row| %> <% row.with_cell(header: true, text: t(".attributes.users.name")) %> diff --git a/app/views/placements/support/schools/mentors/index.html.erb b/app/views/placements/support/schools/mentors/index.html.erb index 45c12c23a..45ee3bfd7 100644 --- a/app/views/placements/support/schools/mentors/index.html.erb +++ b/app/views/placements/support/schools/mentors/index.html.erb @@ -14,7 +14,7 @@ <%= govuk_button_to(t(".add_mentor"), new_placements_support_school_mentor_path, method: :get) %> <% if @mentors.any? %> - <%= govuk_table do |table| %> + <%= app_table do |table| %> <% table.with_head do |head| %> <% head.with_row do |row| %> <% row.with_cell(header: true, text: Mentor.human_attribute_name(:name)) %> diff --git a/app/views/placements/support/schools/placements/index.html.erb b/app/views/placements/support/schools/placements/index.html.erb index 444f1cfcb..d9ce9d971 100644 --- a/app/views/placements/support/schools/placements/index.html.erb +++ b/app/views/placements/support/schools/placements/index.html.erb @@ -9,7 +9,7 @@

    <%= t(".placements") %>

    <% if @placements.any? %> - <%= govuk_table do |table| %> + <%= app_table do |table| %> <% table.with_head do |head| %> <% head.with_row do |row| %> <% row.with_cell(header: true, text: t(".subject")) %> diff --git a/app/views/placements/support/schools/users/index.html.erb b/app/views/placements/support/schools/users/index.html.erb index fc128a55f..0df0ad7fa 100644 --- a/app/views/placements/support/schools/users/index.html.erb +++ b/app/views/placements/support/schools/users/index.html.erb @@ -13,7 +13,7 @@ <%= govuk_button_to(t(".add_user"), new_placements_support_school_user_path(@school), method: :get) %> <% if @users.any? %> - <%= govuk_table do |table| %> + <%= app_table do |table| %> <% table.with_head do |head| %> <% head.with_row do |row| %> <% row.with_cell(header: true, text: t(".attributes.users.name")) %> diff --git a/app/views/placements/support/support_users/index.html.erb b/app/views/placements/support/support_users/index.html.erb index cafd481d9..18c06909a 100644 --- a/app/views/placements/support/support_users/index.html.erb +++ b/app/views/placements/support/support_users/index.html.erb @@ -8,7 +8,7 @@
    - <%= govuk_table do |table| %> + <%= app_table do |table| %> <% table.with_head do |head| %> <% head.with_row do |row| %> <% row.with_cell(text: User.human_attribute_name(:name), width: "govuk-!-width-one-third") %>