Browse Source

feat: more page styling

pull/2142/head
natdeanlewissoftwire 2 years ago
parent
commit
3bb1228049
  1. 2
      app/controllers/form_controller.rb
  2. 4
      app/helpers/logs_helper.rb
  3. 20
      app/services/bulk_upload/lettings/year2023/row_parser.rb
  4. 8
      app/views/bulk_upload_lettings_results/deletion_report.html.erb
  5. 11
      app/views/bulk_upload_lettings_resume/confirm.html.erb

2
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)

4
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)

20
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

8
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 %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<span class="govuk-caption-l">Bulk upload for lettings (<%= @bulk_upload.year_combo %>)</span>
<h1 class="govuk-heading-l"><%= @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) %></h1>
<h1 class="govuk-heading-l"><%= @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) %></h1>
<p>The following cells contain data this is incorrect.</p>
<p>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.</p>
@ -14,7 +18,7 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<% @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 %>
</div>
</div>

11
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 %>
<div class="govuk-button-group">
<%= 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 %>
</div>
</div>
</div>

Loading…
Cancel
Save