Browse Source

Update content of fix choice and confirm pages

pull/1777/head
Kat 3 years ago
parent
commit
29fcdbd46a
  1. 14
      app/helpers/logs_helper.rb
  2. 4
      app/models/bulk_upload.rb
  3. 4
      app/models/forms/bulk_upload_lettings_resume/fix_choice.rb
  4. 4
      app/models/forms/bulk_upload_sales_resume/fix_choice.rb
  5. 6
      app/views/bulk_upload_lettings_resume/confirm.html.erb
  6. 25
      app/views/bulk_upload_lettings_resume/fix_choice.html.erb
  7. 4
      app/views/bulk_upload_lettings_soft_validations_check/confirm.html.erb
  8. 4
      app/views/bulk_upload_sales_resume/confirm.html.erb
  9. 25
      app/views/bulk_upload_sales_resume/fix_choice.html.erb
  10. 4
      app/views/bulk_upload_sales_soft_validations_check/confirm.html.erb
  11. 4
      spec/requests/bulk_upload_lettings_resume_controller_spec.rb
  12. 6
      spec/requests/bulk_upload_lettings_soft_validations_check_controller_spec.rb
  13. 4
      spec/requests/bulk_upload_sales_resume_controller_spec.rb
  14. 6
      spec/requests/bulk_upload_sales_soft_validations_check_controller_spec.rb

14
app/helpers/logs_helper.rb

@ -41,9 +41,15 @@ module LogsHelper
end end
end end
def pluralize_logs_and_errors_warning(log_count, error_count) def logs_and_errors_warning(bulk_upload)
is_or_are = log_count == 1 ? "is" : "are" this_or_these_errors = bulk_upload.bulk_upload_errors.count == 1 ? "This error" : "These errors"
need_or_needs = error_count == 1 ? "needs" : "need"
"There #{is_or_are} #{pluralize(log_count, 'log')} in this bulk upload with #{pluralize(error_count, 'error')} that still #{need_or_needs} to be fixed after upload." "You will upload #{pluralize(bulk_upload.total_logs_count, 'log')}. There are errors in #{pluralize(bulk_upload.logs_with_errors_count, 'log')}, and #{pluralize(bulk_upload.bulk_upload_errors.count, 'error')} in total. #{this_or_these_errors} will need to be fixed on the CORE site."
end
def logs_and_soft_validations_warning(bulk_upload)
this_or_these_unexpected_answers = bulk_upload.bulk_upload_errors.count == 1 ? "This unexpected answer" : "These unexpected answers"
"You will upload #{pluralize(bulk_upload.total_logs_count, 'log')}. There are unexpected answers in #{pluralize(bulk_upload.logs_with_errors_count, 'log')}, and #{pluralize(bulk_upload.bulk_upload_errors.count, 'unexpected answer')} in total. #{this_or_these_unexpected_answers} will be marked as correct."
end end
end end

4
app/models/bulk_upload.rb

@ -107,6 +107,10 @@ class BulkUpload < ApplicationRecord
end end
end end
def logs_with_errors_count
bulk_upload_errors.distinct.count("row")
end
private private
def generate_identifier def generate_identifier

4
app/models/forms/bulk_upload_lettings_resume/fix_choice.rb

@ -39,9 +39,9 @@ module Forms
def recommendation def recommendation
if BulkUploadErrorSummaryTableComponent.new(bulk_upload:).errors? if BulkUploadErrorSummaryTableComponent.new(bulk_upload:).errors?
"For this many errors we recommend to fix errors in the CSV and re-upload as you may be able to edit many fields at once in a CSV." "We recommend fixing these errors in the CSV, as you may be able to edit multiple fields at once. However, you can also upload these logs and fix the errors on the CORE site."
else else
"For this many errors we recommend to upload logs and fix errors on site as you can easily see the questions and select the appropriate answer." "We recommend uploading logs and fixing errors on site as you can easily see the questions and select the appropriate answer. However, you can also fix these errors in the CSV."
end end
end end

4
app/models/forms/bulk_upload_sales_resume/fix_choice.rb

@ -39,9 +39,9 @@ module Forms
def recommendation def recommendation
if BulkUploadErrorSummaryTableComponent.new(bulk_upload:).errors? if BulkUploadErrorSummaryTableComponent.new(bulk_upload:).errors?
"For this many errors we recommend to fix errors in the CSV and re-upload as you may be able to edit many fields at once in a CSV." "We recommend fixing these errors in the CSV, as you may be able to edit multiple fields at once. However, you can also upload these logs and fix the errors on the CORE site."
else else
"For this many errors we recommend to upload logs and fix errors on site as you can easily see the questions and select the appropriate answer." "We recommend uploading logs and fixing errors on site as you can easily see the questions and select the appropriate answer. However, you can also fix these errors in the CSV."
end end
end end

6
app/views/bulk_upload_lettings_resume/confirm.html.erb

@ -5,12 +5,12 @@
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<span class="govuk-caption-l">Bulk upload for lettings (<%= @bulk_upload.year_combo %>)</span> <span class="govuk-caption-l">Bulk upload for lettings (<%= @bulk_upload.year_combo %>)</span>
<h1 class="govuk-heading-l">Are you sure you want to upload all logs from this bulk upload?</h1> <h1 class="govuk-heading-l">You have chosen to upload all logs from this bulk upload.</h1>
<p class="govuk-body"><%= pluralize_logs_and_errors_warning(@bulk_upload.logs.count, @bulk_upload.bulk_upload_errors.count) %> </p> <p class="govuk-body"><%= logs_and_errors_warning(@bulk_upload) %></p>
<%= form_with model: @form, scope: :form, url: page_bulk_upload_lettings_resume_path(@bulk_upload, page: "confirm"), method: :patch do |f| %> <%= form_with model: @form, scope: :form, url: page_bulk_upload_lettings_resume_path(@bulk_upload, page: "confirm"), method: :patch do |f| %>
<%= f.govuk_submit %> <%= f.govuk_submit "Confirm" %>
<%= govuk_button_link_to "Cancel", @form.back_path, secondary: true %> <%= govuk_button_link_to "Cancel", @form.back_path, secondary: true %>
<% end %> <% end %>

25
app/views/bulk_upload_lettings_resume/fix_choice.html.erb

@ -4,24 +4,33 @@
<%= f.govuk_error_summary %> <%= f.govuk_error_summary %>
<span class="govuk-caption-l">Bulk upload for lettings (<%= @bulk_upload.year_combo %>)</span> <span class="govuk-caption-l">Bulk upload for lettings (<%= @bulk_upload.year_combo %>)</span>
<h1 class="govuk-heading-l">How would you like to fix <%= pluralize(@bulk_upload.bulk_upload_errors.count, "error") %>?</h1> <h1 class="govuk-heading-l">How would you like to fix the errors?</h1>
<div class="govuk-body-l"> <div class="govuk-body-l">
File: <%= @bulk_upload.filename %> File: <%= @bulk_upload.filename %>
</div> </div>
<div class="govuk-body">
You have tried to upload <%= @bulk_upload.total_logs_count ? pluralize(@bulk_upload.total_logs_count, "log") : "logs" %>. There are errors in <%= pluralize(@bulk_upload.logs_with_errors_count, "log") %>, and <%= pluralize(@bulk_upload.bulk_upload_errors.count, "error") %> in total.
</div>
<div class="govuk-body"> <div class="govuk-body">
<%= @form.recommendation %> <%= @form.recommendation %>
</div> </div>
<%= govuk_details(summary_text: "How to choose between fixing errors on the CORE site or in the CSV") do %> <%= govuk_details(summary_text: "How to choose between fixing errors on the CORE site or in the CSV") do %>
<p class="govuk-body">When it comes to fixing errors, there are pros and cons to doing it on a CSV versus doing it on a website.</p> <p class="govuk-body govuk-!-margin-bottom-2">You may find it easier to fix the errors in the CSV file if:</p>
<ul class="govuk-list govuk-list--bullet">
<p class="govuk-body">Fixing errors on a CSV file can be beneficial because it allows you to easily make changes to multiple records at once, and you can use tools like Excel to quickly identify and correct errors. However, if the CSV file is not properly formatted, it can be difficult to identify which records contain errors.</p> <li>you have a lot of errors</li>
<li>the CSV file is formatted incorrectly and you can see where the errors are</li>
<p class="govuk-body">Fixing errors on a website can be convenient because you can see the data in context and make changes in real-time. However, this approach can be time-consuming if you need to make changes to multiple records, and it may be more difficult to identify errors in a large dataset.</p> <li>you need to fix multiple errors at once</li>
</ul>
<p class="govuk-body">Ultimately, the best approach will depend on the specific situation and the nature of the errors that need to be fixed.</p> <p class="govuk-body govuk-!-margin-bottom-2">You may find it easier to fix the errors on the CORE site if:</p>
<ul class="govuk-list govuk-list--bullet">
<li>you need to see the data in context</li>
<li>you have a smaller file, with a few errors</li>
<li>you are not sure where the errors are</li>
</ul>
<% end %> <% end %>
<%= f.govuk_collection_radio_buttons :choice, <%= f.govuk_collection_radio_buttons :choice,

4
app/views/bulk_upload_lettings_soft_validations_check/confirm.html.erb

@ -5,9 +5,9 @@
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<span class="govuk-caption-l">Bulk upload for lettings (<%= @bulk_upload.year_combo %>)</span> <span class="govuk-caption-l">Bulk upload for lettings (<%= @bulk_upload.year_combo %>)</span>
<h1 class="govuk-heading-l">Are you sure you want to upload all logs from this bulk upload?</h1> <h1 class="govuk-heading-l">You have chosen to upload all logs from this bulk upload.</h1>
<p class="govuk-body">There are <%= pluralize(@bulk_upload.logs.count, "log") %> in this bulk upload, and <%= pluralize(@bulk_upload.bulk_upload_errors.count, "unexpected answer") %> will be marked as correct.</p> <p class="govuk-body"><%= logs_and_soft_validations_warning(@bulk_upload) %></p>
<%= form_with model: @form, scope: :form, url: page_bulk_upload_lettings_soft_validations_check_path(@bulk_upload, page: "confirm"), method: :patch do |f| %> <%= form_with model: @form, scope: :form, url: page_bulk_upload_lettings_soft_validations_check_path(@bulk_upload, page: "confirm"), method: :patch do |f| %>
<%= f.govuk_submit %> <%= f.govuk_submit %>

4
app/views/bulk_upload_sales_resume/confirm.html.erb

@ -5,9 +5,9 @@
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<span class="govuk-caption-l">Bulk upload for sales (<%= @bulk_upload.year_combo %>)</span> <span class="govuk-caption-l">Bulk upload for sales (<%= @bulk_upload.year_combo %>)</span>
<h1 class="govuk-heading-l">Are you sure you want to upload all logs from this bulk upload?</h1> <h1 class="govuk-heading-l">You have chosen to upload all logs from this bulk upload.</h1>
<p class="govuk-body">There are <%= pluralize(@bulk_upload.logs.count, "log") %> in this bulk upload with <%= pluralize(@bulk_upload.bulk_upload_errors.count, "error") %> that still need to be fixed after upload.</p> <p class="govuk-body"><%= logs_and_errors_warning(@bulk_upload) %></p>
<%= form_with model: @form, scope: :form, url: page_bulk_upload_sales_resume_path(@bulk_upload, page: "confirm"), method: :patch do |f| %> <%= form_with model: @form, scope: :form, url: page_bulk_upload_sales_resume_path(@bulk_upload, page: "confirm"), method: :patch do |f| %>
<%= f.govuk_submit %> <%= f.govuk_submit %>

25
app/views/bulk_upload_sales_resume/fix_choice.html.erb

@ -4,24 +4,33 @@
<%= f.govuk_error_summary %> <%= f.govuk_error_summary %>
<span class="govuk-caption-l">Bulk upload for sales (<%= @bulk_upload.year_combo %>)</span> <span class="govuk-caption-l">Bulk upload for sales (<%= @bulk_upload.year_combo %>)</span>
<h1 class="govuk-heading-l">How would you like to fix <%= pluralize(@bulk_upload.bulk_upload_errors.count, "error") %>?</h1> <h1 class="govuk-heading-l">How would you like to fix the errors?</h1>
<div class="govuk-body-l"> <div class="govuk-body-l">
File: <%= @bulk_upload.filename %> File: <%= @bulk_upload.filename %>
</div> </div>
<div class="govuk-body">
You have tried to upload <%= @bulk_upload.total_logs_count ? pluralize(@bulk_upload.total_logs_count, "log") : "logs" %>. There are errors in <%= pluralize(@bulk_upload.logs_with_errors_count, "log") %>, and <%= pluralize(@bulk_upload.bulk_upload_errors.count, "error") %> in total.
</div>
<div class="govuk-body"> <div class="govuk-body">
<%= @form.recommendation %> <%= @form.recommendation %>
</div> </div>
<%= govuk_details(summary_text: "How to choose between fixing errors on the CORE site or in the CSV") do %> <%= govuk_details(summary_text: "How to choose between fixing errors on the CORE site or in the CSV") do %>
<p class="govuk-body">When it comes to fixing errors, there are pros and cons to doing it on a CSV versus doing it on a website.</p> <p class="govuk-body govuk-!-margin-bottom-2">You may find it easier to fix the errors in the CSV file if:</p>
<ul class="govuk-list govuk-list--bullet">
<p class="govuk-body">Fixing errors on a CSV file can be beneficial because it allows you to easily make changes to multiple records at once, and you can use tools like Excel to quickly identify and correct errors. However, if the CSV file is not properly formatted, it can be difficult to identify which records contain errors.</p> <li>you have a lot of errors</li>
<li>the CSV file is formatted incorrectly and you can see where the errors are</li>
<p class="govuk-body">Fixing errors on a website can be convenient because you can see the data in context and make changes in real-time. However, this approach can be time-consuming if you need to make changes to multiple records, and it may be more difficult to identify errors in a large dataset.</p> <li>you need to fix multiple errors at once</li>
</ul>
<p class="govuk-body">Ultimately, the best approach will depend on the specific situation and the nature of the errors that need to be fixed.</p> <p class="govuk-body govuk-!-margin-bottom-2">You may find it easier to fix the errors on the CORE site if:</p>
<ul class="govuk-list govuk-list--bullet">
<li>you need to see the data in context</li>
<li>you have a smaller file, with a few errors</li>
<li>you are not sure where the errors are</li>
</ul>
<% end %> <% end %>
<%= f.govuk_collection_radio_buttons :choice, <%= f.govuk_collection_radio_buttons :choice,

4
app/views/bulk_upload_sales_soft_validations_check/confirm.html.erb

@ -5,9 +5,9 @@
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<span class="govuk-caption-l">Bulk upload for sales (<%= @bulk_upload.year_combo %>)</span> <span class="govuk-caption-l">Bulk upload for sales (<%= @bulk_upload.year_combo %>)</span>
<h1 class="govuk-heading-l">Are you sure you want to upload all logs from this bulk upload?</h1> <h1 class="govuk-heading-l">You have chosen to upload all logs from this bulk upload.</h1>
<p class="govuk-body">There are <%= pluralize(@bulk_upload.logs.count, "log") %> in this bulk upload, and <%= pluralize(@bulk_upload.bulk_upload_errors.count, "unexpected answer") %> will be marked as correct.</p> <p class="govuk-body"><%= logs_and_soft_validations_warning(@bulk_upload) %></p>
<%= form_with model: @form, scope: :form, url: page_bulk_upload_sales_soft_validations_check_path(@bulk_upload, page: "confirm"), method: :patch do |f| %> <%= form_with model: @form, scope: :form, url: page_bulk_upload_sales_soft_validations_check_path(@bulk_upload, page: "confirm"), method: :patch do |f| %>
<%= f.govuk_submit %> <%= f.govuk_submit %>

4
spec/requests/bulk_upload_lettings_resume_controller_spec.rb

@ -25,7 +25,7 @@ RSpec.describe BulkUploadLettingsResumeController, type: :request do
expect(response.body).to include("Bulk upload for lettings") expect(response.body).to include("Bulk upload for lettings")
expect(response.body).to include("2022/23") expect(response.body).to include("2022/23")
expect(response.body).to include("How would you like to fix 2 errors?") expect(response.body).to include("How would you like to fix the errors?")
expect(response.body).to include(bulk_upload.filename) expect(response.body).to include(bulk_upload.filename)
expect(response.body).not_to include("Cancel") expect(response.body).not_to include("Cancel")
end end
@ -106,7 +106,7 @@ RSpec.describe BulkUploadLettingsResumeController, type: :request do
expect(response).to be_successful expect(response).to be_successful
expect(response.body).to include("Are you sure") expect(response.body).to include("You have chosen to upload all logs from this bulk upload.")
end end
it "sets no cache headers" do it "sets no cache headers" do

6
spec/requests/bulk_upload_lettings_soft_validations_check_controller_spec.rb

@ -2,7 +2,7 @@ require "rails_helper"
RSpec.describe BulkUploadLettingsSoftValidationsCheckController, type: :request do RSpec.describe BulkUploadLettingsSoftValidationsCheckController, type: :request do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:bulk_upload) { create(:bulk_upload, :lettings, user:, bulk_upload_errors:) } let(:bulk_upload) { create(:bulk_upload, :lettings, user:, bulk_upload_errors:, total_logs_count: 2) }
let(:bulk_upload_errors) { create_list(:bulk_upload_error, 2) } let(:bulk_upload_errors) { create_list(:bulk_upload_error, 2) }
before do before do
@ -98,8 +98,8 @@ RSpec.describe BulkUploadLettingsSoftValidationsCheckController, type: :request
expect(response).to be_successful expect(response).to be_successful
expect(response.body).to include("Are you sure you want to upload all logs from this bulk upload?") expect(response.body).to include("You have chosen to upload all logs from this bulk upload.")
expect(response.body).to include("There are 2 logs in this bulk upload, and 2 unexpected answers will be marked as correct.") expect(response.body).to include("You will upload 2 logs. There are unexpected answers in 2 logs, and 2 unexpected answers in total. These unexpected answers will be marked as correct.")
expect(response.body).not_to include("You’ve successfully uploaded") expect(response.body).not_to include("You’ve successfully uploaded")
end end
end end

4
spec/requests/bulk_upload_sales_resume_controller_spec.rb

@ -25,7 +25,7 @@ RSpec.describe BulkUploadSalesResumeController, type: :request do
expect(response.body).to include("Bulk upload for sales") expect(response.body).to include("Bulk upload for sales")
expect(response.body).to include("2022/23") expect(response.body).to include("2022/23")
expect(response.body).to include("How would you like to fix 2 errors?") expect(response.body).to include("How would you like to fix the errors?")
expect(response.body).to include(bulk_upload.filename) expect(response.body).to include(bulk_upload.filename)
expect(response.body).not_to include("Cancel") expect(response.body).not_to include("Cancel")
end end
@ -106,7 +106,7 @@ RSpec.describe BulkUploadSalesResumeController, type: :request do
expect(response).to be_successful expect(response).to be_successful
expect(response.body).to include("Are you sure") expect(response.body).to include("You have chosen to upload all logs from this bulk upload.")
end end
it "sets no cache headers" do it "sets no cache headers" do

6
spec/requests/bulk_upload_sales_soft_validations_check_controller_spec.rb

@ -2,7 +2,7 @@ require "rails_helper"
RSpec.describe BulkUploadSalesSoftValidationsCheckController, type: :request do RSpec.describe BulkUploadSalesSoftValidationsCheckController, type: :request do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:bulk_upload) { create(:bulk_upload, :sales, user:, bulk_upload_errors:) } let(:bulk_upload) { create(:bulk_upload, :sales, user:, bulk_upload_errors:, total_logs_count: 2) }
let(:bulk_upload_errors) { create_list(:bulk_upload_error, 2) } let(:bulk_upload_errors) { create_list(:bulk_upload_error, 2) }
before do before do
@ -98,8 +98,8 @@ RSpec.describe BulkUploadSalesSoftValidationsCheckController, type: :request do
expect(response).to be_successful expect(response).to be_successful
expect(response.body).to include("Are you sure you want to upload all logs from this bulk upload?") expect(response.body).to include("You have chosen to upload all logs from this bulk upload.")
expect(response.body).to include("There are 2 logs in this bulk upload, and 2 unexpected answers will be marked as correct.") expect(response.body).to include("You will upload 2 logs. There are unexpected answers in 2 logs, and 2 unexpected answers in total. These unexpected answers will be marked as correct.")
expect(response.body).not_to include("You’ve successfully uploaded") expect(response.body).not_to include("You’ve successfully uploaded")
end end
end end

Loading…
Cancel
Save