From 3bb1228049a314c99aa44a88b67e1639b540865b Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Tue, 16 Jan 2024 10:36:34 +0000 Subject: [PATCH] feat: more page styling --- app/controllers/form_controller.rb | 2 +- app/helpers/logs_helper.rb | 4 ++-- .../lettings/year2023/row_parser.rb | 20 +++++++++---------- .../deletion_report.html.erb | 8 ++++++-- .../confirm.html.erb | 11 +++++----- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/app/controllers/form_controller.rb b/app/controllers/form_controller.rb index 2f6ce6483..11f2aa9cf 100644 --- a/app/controllers/form_controller.rb +++ b/app/controllers/form_controller.rb @@ -15,7 +15,7 @@ class FormController < ApplicationController redirect_to(successful_redirect_path) else mandatory_questions_with_no_response.map do |question| - @log.errors.add question.id.to_sym, question.unanswered_error_message + @log.errors.add question.id.to_sym, question.unanswered_error_message, category: :not_answered end Rails.logger.info "User triggered validation(s) on: #{@log.errors.map(&:attribute).join(', ')}" @subsection = form.subsection_for_page(@page) diff --git a/app/helpers/logs_helper.rb b/app/helpers/logs_helper.rb index 71b345c91..e50c8b140 100644 --- a/app/helpers/logs_helper.rb +++ b/app/helpers/logs_helper.rb @@ -50,9 +50,9 @@ module LogsHelper def logs_and_errors_warning(bulk_upload) is_or_are = bulk_upload.total_logs_count == 1 ? "is" : "are" - need_or_needs = bulk_upload.bulk_upload_errors.count == 1 ? "needs" : "need" + needs_or_need = bulk_upload.bulk_upload_errors.count == 1 ? "needs" : "need" - "There #{is_or_are} #{pluralize(bulk_upload.total_logs_count, 'log')} in this bulk upload with #{pluralize(bulk_upload.bulk_upload_errors.count, 'error')} that still #{need_or_needs} to be fixed after upload." + "There #{is_or_are} #{pluralize(bulk_upload.total_logs_count, 'log')} in this bulk upload with #{pluralize(bulk_upload.bulk_upload_errors.count, 'error')} that still #{needs_or_need} to be fixed after upload." end def logs_and_soft_validations_warning(bulk_upload) diff --git a/app/services/bulk_upload/lettings/year2023/row_parser.rb b/app/services/bulk_upload/lettings/year2023/row_parser.rb index 508ddea90..eb5716511 100644 --- a/app/services/bulk_upload/lettings/year2023/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2023/row_parser.rb @@ -539,7 +539,7 @@ private def validate_uprn_exists_if_any_key_address_fields_are_blank if field_18.blank? && (field_19.blank? || field_21.blank?) - errors.add(:field_18, I18n.t("validations.not_answered", question: "UPRN")) + errors.add(:field_18, I18n.t("validations.not_answered", question: "UPRN"), category: :not_answered) end end @@ -623,10 +623,10 @@ private def validate_no_housing_needs_questions_answered if [field_83, field_84, field_85, field_86, field_87, field_88].all?(&:blank?) - errors.add(:field_87, I18n.t("validations.not_answered", question: "anybody with disabled access needs")) - errors.add(:field_86, I18n.t("validations.not_answered", question: "other access needs")) + errors.add(:field_87, I18n.t("validations.not_answered", question: "anybody with disabled access needs"), category: :not_answered) + errors.add(:field_86, I18n.t("validations.not_answered", question: "other access needs"), category: :not_answered) %i[field_83 field_84 field_85].each do |field| - errors.add(field, I18n.t("validations.not_answered", question: "disabled access needs type")) + errors.add(field, I18n.t("validations.not_answered", question: "disabled access needs type"), category: :not_answered) end end end @@ -635,7 +635,7 @@ private reason_fields = %i[field_111 field_112 field_113 field_114 field_115] if field_110 == 1 && reason_fields.all? { |field| attributes[field.to_s].blank? } reason_fields.each do |field| - errors.add(field, I18n.t("validations.not_answered", question: "reason for reasonable preference")) + errors.add(field, I18n.t("validations.not_answered", question: "reason for reasonable preference"), category: :not_answered) end end end @@ -650,16 +650,16 @@ private end elsif illness_option_fields.all? { |field| attributes[field.to_s].blank? } illness_option_fields.each do |field| - errors.add(field, I18n.t("validations.not_answered", question: "how is person affected by condition or illness")) + errors.add(field, I18n.t("validations.not_answered", question: "how is person affected by condition or illness"), category: :not_answered) end end end def validate_lettings_allocation if cbl.blank? && cap.blank? && chr.blank? - errors.add(:field_116, I18n.t("validations.not_answered", question: "was the letting made under the Choice-Based Lettings (CBL)?")) - errors.add(:field_117, I18n.t("validations.not_answered", question: "was the letting made under the Common Allocation Policy (CAP)?")) - errors.add(:field_118, I18n.t("validations.not_answered", question: "was the letting made under the Common Housing Register (CHR)?")) + errors.add(:field_116, I18n.t("validations.not_answered", question: "was the letting made under the Choice-Based Lettings (CBL)?"), category: :not_answered) + errors.add(:field_117, I18n.t("validations.not_answered", question: "was the letting made under the Common Allocation Policy (CAP)?"), category: :not_answered) + errors.add(:field_118, I18n.t("validations.not_answered", question: "was the letting made under the Common Housing Register (CHR)?"), category: :not_answered) end end @@ -743,7 +743,7 @@ private fields.each do |field| unless errors.any? { |e| fields.include?(e.attribute) } question_text = question.error_display_label.presence || "this question" - errors.add(field, I18n.t("validations.not_answered", question: question_text.downcase)) + errors.add(field, I18n.t("validations.not_answered", question: question_text.downcase), category: :not_answered) end end end diff --git a/app/views/bulk_upload_lettings_results/deletion_report.html.erb b/app/views/bulk_upload_lettings_results/deletion_report.html.erb index b71dad333..e1b14000c 100644 --- a/app/views/bulk_upload_lettings_results/deletion_report.html.erb +++ b/app/views/bulk_upload_lettings_results/deletion_report.html.erb @@ -1,7 +1,11 @@ +<% content_for :before_content do %> + <%= govuk_back_link(href: :back) %> +<% end %> +
Bulk upload for lettings (<%= @bulk_upload.year_combo %>) -

<%= @bulk_upload.bulk_upload_errors.uniq(&:field).count == 1 ? "This" : "These" %> <%= pluralize(@bulk_upload.bulk_upload_errors.uniq(&:field).count, "answer") %> will be deleted if you upload the <%= "log".pluralize(@bulk_upload.logs.count) %>

+

<%= @bulk_upload.bulk_upload_errors.select{|e| e.category != :not_answered}.uniq(&:field).count == 1 ? "This" : "These" %> <%= pluralize(@bulk_upload.bulk_upload_errors.select{|e| e.category != :not_answered}.uniq(&:field).count, "answer") %> will be deleted if you upload the <%= "log".pluralize(@bulk_upload.logs.count) %>

The following cells contain data this is incorrect.

If you upload the logs, these answers will be deleted. You will have to re-enter the data on the site and resolve these errors.

@@ -14,7 +18,7 @@
<% @bulk_upload.bulk_upload_errors.order_by_row.order_by_cell.group_by(&:row).each do |_row, errors_for_row| %> - <%= render BulkUploadErrorRowComponent.new(bulk_upload_errors: errors_for_row) %> + <%= render BulkUploadErrorRowComponent.new(bulk_upload_errors: errors_for_row.select{|e| e.category != :not_answered}) %> <% end %>
diff --git a/app/views/bulk_upload_lettings_resume/confirm.html.erb b/app/views/bulk_upload_lettings_resume/confirm.html.erb index 9d839576d..9336b3eb8 100644 --- a/app/views/bulk_upload_lettings_resume/confirm.html.erb +++ b/app/views/bulk_upload_lettings_resume/confirm.html.erb @@ -17,10 +17,11 @@ <%= govuk_link_to "See which answers will be deleted", deletion_report_bulk_upload_lettings_result_path %> <% end %> - <%= form_with model: @form, scope: :form, url: page_bulk_upload_lettings_resume_path(@bulk_upload, page: "confirm"), method: :patch do |f| %> - <%= f.govuk_submit "Confirm" %> - - <%= govuk_button_link_to "Cancel", @form.back_path, secondary: true %> - <% end %> +
+ <%= form_with model: @form, scope: :form, url: page_bulk_upload_lettings_resume_path(@bulk_upload, page: "confirm"), method: :patch do |f| %> + <%= f.govuk_submit "Confirm" %> + <%= govuk_button_link_to "Cancel", @form.back_path, secondary: true %> + <% end %> +