From a65ee5676f5188a9cbde7d2ad86907f8a190b504 Mon Sep 17 00:00:00 2001
From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com>
Date: Tue, 22 Oct 2024 14:14:53 +0100
Subject: [PATCH] CLDC-2399: Bulk upload table styling (#2714)
---
.../bulk_upload_error_row_component.html.erb | 30 +++++++++----------
.../bulk_upload_error_row_component.rb | 13 ++++++++
app/frontend/styles/_bulk-uploads.scss | 5 ++++
3 files changed, 33 insertions(+), 15 deletions(-)
diff --git a/app/components/bulk_upload_error_row_component.html.erb b/app/components/bulk_upload_error_row_component.html.erb
index 65e38613f..4bd303957 100644
--- a/app/components/bulk_upload_error_row_component.html.erb
+++ b/app/components/bulk_upload_error_row_component.html.erb
@@ -13,7 +13,7 @@
<% if critical_errors.any? %>
Critical errors
These errors must be fixed to complete your logs.
- <%= govuk_table do |table| %>
+ <%= govuk_table(html_attributes: { class: potential_errors.any? ? "" : "no-bottom-border" }) do |table| %>
<%= table.with_head do |head| %>
<% head.with_row do |row| %>
<% row.with_cell(header: true, text: "Cell") %>
@@ -39,7 +39,7 @@
<% if potential_errors.any? %>
Potential errors
The following groups of cells might have conflicting data. Check the answers and fix any incorrect data.
If the answers are correct, fix the critical errors and reupload the file. You'll need to confirm that the following data is correct when the file only contains potential errors.
- <%= govuk_table do |table| %>
+ <%= govuk_table(html_attributes: { class: "no-bottom-border" }) do |table| %>
<%= table.with_head do |head| %>
<% head.with_row do |row| %>
<% row.with_cell(header: true, text: "Cell") %>
@@ -49,24 +49,24 @@
<% end %>
<% end %>
- <%= table.with_body do |body| %>
- <% potential_errors.group_by(&:error).each do |error_message, errors| %>
- <% errors.each_with_index do |error, index| %>
- <% row_class = "grouped-rows" %>
- <% row_class += " first-row" if index.zero? %>
- <% row_class += " last-row" if index == errors.size - 1 %>
- <% body.with_row(html_attributes: { class: row_class }) do |row| %>
- <% row.with_cell(text: error.cell) %>
- <% row.with_cell(text: question_for_field(error.field), html_attributes: { class: "govuk-!-width-one-half" }) %>
- <% if index == 0 %>
- <% row.with_cell(text: error_message.html_safe, rowspan: errors.size, html_attributes: { class: "govuk-!-font-weight-bold govuk-!-width-one-half grouped-multirow-cell" }) %>
- <% end %>
- <% row.with_cell(text: error.field.humanize) %>
+ <%= table.with_body do |body| %>
+ <% potential_errors.group_by(&:error).each_with_index do |(error_message, errors), group_index| %>
+ <% total_groups = potential_errors.group_by(&:error).size %>
+ <% errors.each_with_index do |error, index| %>
+ <% row_class = row_classes(index, errors.size) %>
+ <% body.with_row(html_attributes: { class: row_class }) do |row| %>
+ <% row.with_cell(text: error.cell) %>
+ <% row.with_cell(text: question_for_field(error.field), html_attributes: { class: "govuk-!-width-one-half" }) %>
+ <% if index == 0 %>
+ <% cell_class = cell_classes(group_index, total_groups) %>
+ <% row.with_cell(text: error_message.html_safe, rowspan: errors.size, html_attributes: { class: cell_class }) %>
<% end %>
+ <% row.with_cell(text: error.field.humanize) %>
<% end %>
<% end %>
<% end %>
<% end %>
+ <% end %>
<% end %>
diff --git a/app/components/bulk_upload_error_row_component.rb b/app/components/bulk_upload_error_row_component.rb
index 887eef10c..1cb4de9d8 100644
--- a/app/components/bulk_upload_error_row_component.rb
+++ b/app/components/bulk_upload_error_row_component.rb
@@ -62,4 +62,17 @@ class BulkUploadErrorRowComponent < ViewComponent::Base
def sales?
bulk_upload.log_type == "sales"
end
+
+ def row_classes(index, errors_size)
+ row_class = "grouped-rows"
+ row_class += " first-row" if index.zero?
+ row_class += " last-row" if index == errors_size - 1
+ row_class
+ end
+
+ def cell_classes(group_index, total_groups)
+ cell_class = "govuk-!-font-weight-bold govuk-!-width-one-half"
+ cell_class += " grouped-multirow-cell" unless group_index == total_groups - 1
+ cell_class
+ end
end
diff --git a/app/frontend/styles/_bulk-uploads.scss b/app/frontend/styles/_bulk-uploads.scss
index eceae6565..65213ee82 100644
--- a/app/frontend/styles/_bulk-uploads.scss
+++ b/app/frontend/styles/_bulk-uploads.scss
@@ -12,6 +12,11 @@
border-bottom: 1px solid #b1b4b6;
}
+.no-bottom-border,
+.no-bottom-border > tbody > tr:last-of-type td {
+ border-bottom: none;
+}
+
.text-normal-break {
white-space: normal;
word-break: break-all;