From db153b4af1fb85deef8cab6ac8989e191390629f Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Mon, 5 Aug 2024 11:27:13 +0100 Subject: [PATCH] Iterate over errors once & styling --- app/components/bulk_upload_error_row_component.html.erb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/components/bulk_upload_error_row_component.html.erb b/app/components/bulk_upload_error_row_component.html.erb index 0ddc17baf..d35ddc345 100644 --- a/app/components/bulk_upload_error_row_component.html.erb +++ b/app/components/bulk_upload_error_row_component.html.erb @@ -8,6 +8,7 @@
+ <% potential_errors, critical_errors = bulk_upload_errors.partition { |error| error.category == "soft_validation" } %>

Critical errors

These errors must be fixed to complete your logs.

<%= govuk_table do |table| %> @@ -20,11 +21,11 @@ <% end %> <%= table.with_body do |body| %> - <% bulk_upload_errors.reject { |error| error.category == "soft_validation" }.each do |error| %> + <% critical_errors.each do |error| %> <% body.with_row do |row| %> <% row.with_cell(text: error.cell) %> <% row.with_cell(text: question_for_field(error.field)) %> - <% row.with_cell(header: true, text: error.error) %> + <% row.with_cell(text: error.error, html_attributes: {class: "govuk-!-font-weight-bold"}) %> <% row.with_cell(text: error.field.humanize) %> <% end %> <% end %> @@ -32,7 +33,6 @@ <% end %> <% end %> - <% potential_errors = bulk_upload_errors.select { |error| error.category == "soft_validation" } %> <% 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.

@@ -56,7 +56,7 @@ <% row.with_cell(text: error.cell) %> <% row.with_cell(text: question_for_field(error.field)) %> <% if index == 0 %> - <% row.with_cell(header: true, text: error_message, rowspan: errors.size) %> + <% row.with_cell(text: error_message, rowspan: errors.size, html_attributes: {class: "govuk-!-font-weight-bold"}) %> <% end %> <% row.with_cell(text: error.field.humanize) %> <% end %>