From 1cbb72c671f2f465869c50fcc73280cd75557c8d Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Wed, 25 Sep 2024 15:19:16 +0100 Subject: [PATCH] Use AppSessionTableComponent This updates the two views where we display a list of sessions to use the new `AppSessionTableComponent` that was added in the previous commit. --- app/views/programmes/sessions.html.erb | 55 +++----------------------- app/views/sessions/index.html.erb | 33 +--------------- 2 files changed, 6 insertions(+), 82 deletions(-) diff --git a/app/views/programmes/sessions.html.erb b/app/views/programmes/sessions.html.erb index 3df2d980c..3d0d8d0d6 100644 --- a/app/views/programmes/sessions.html.erb +++ b/app/views/programmes/sessions.html.erb @@ -11,55 +11,10 @@ <%= render AppProgrammeNavigationComponent.new(@programme, active: :sessions) %> -<% [[@in_progress_sessions, "In progress sessions"], - [@future_sessions, "Planned sessions"], - [@past_sessions, "Past sessions"]] - .select { |sessions, _| sessions.any? }.each do |sessions, title| %> -
-

<%= title %>

- <%= govuk_table(html_attributes: { class: "nhsuk-table-responsive" }) do |table| %> - <% table.with_head do |head| %> - <% head.with_row do |row| %> - <% row.with_cell(text: "Dates") %> - <% row.with_cell(text: "Location") %> - <% row.with_cell(text: "Consent period") %> - <% row.with_cell(text: "Cohort") %> - <% end %> - <% end %> +<% [[@in_progress_sessions, "active session"], + [@future_sessions, "planned session"], + [@past_sessions, "past session"]] + .select { |sessions, _| sessions.any? }.each do |sessions, description| %> - <% table.with_body do |body| %> - <% sessions.each do |session| %> - <% body.with_row do |row| %> - <% row.with_cell do %> - Dates - <%= safe_join(session.dates.map { _1.value.to_fs(:long) }, tag.br) %> - <% end %> - <% row.with_cell do %> - Location -

- <%= link_to session_location(session), session_path(session) %> - <% if (location = session.location)&.has_address? %> -
<%= format_address_single_line(location) %> - <% end %> -

- <% end %> - <% row.with_cell do %> - Consent period - <% if session.close_consent_at.nil? %> - n/a - <% elsif session.close_consent_at.past? %> - <%= "Closed #{session.close_consent_at.to_fs(:short)}" %> - <% else %> - <%= "Open until #{session.close_consent_at.to_fs(:short)}" %> - <% end %> - <% end %> - <% row.with_cell(numeric: true) do %> - Cohort - <%= session.patients.count %> - <% end %> - <% end %> - <% end %> - <% end %> - <% end %> -
+ <%= render AppSessionTableComponent.new(sessions, description:, show_consent_period: true) %> <% end %> diff --git a/app/views/sessions/index.html.erb b/app/views/sessions/index.html.erb index 1ac3c7c6d..3b0c800a0 100644 --- a/app/views/sessions/index.html.erb +++ b/app/views/sessions/index.html.erb @@ -6,36 +6,5 @@ <% if @sessions.empty? %>

There are no sessions scheduled for today.

<% else %> -
-

<%= pluralize(@sessions.count, "sessions") %>

- - <%= govuk_table(html_attributes: { class: "nhsuk-table-responsive" }) do |table| %> - <% table.with_head do |head| %> - <% head.with_row do |row| %> - <% row.with_cell(text: "Location") %> - <% row.with_cell(text: "Cohort") %> - <% end %> - <% end %> - - <% table.with_body do |body| %> - <% @sessions.each do |session| %> - <% body.with_row do |row| %> - <% row.with_cell do %> - Location -

- <%= link_to session_location(session), session_path(session) %> - <% if (location = session.location)&.has_address? %> -
<%= format_address_single_line(location) %> - <% end %> -

- <% end %> - <% row.with_cell do %> - Cohort - <%= session.patients.count %> - <% end %> - <% end %> - <% end %> - <% end %> - <% end %> -
+ <%= render AppSessionTableComponent.new(@sessions, description: "active session", show_programmes: true) %> <% end %>