Browse Source

refactor: move pluralizer to helper

pull/1570/head
natdeanlewissoftwire 3 years ago
parent
commit
9e644d9165
  1. 6
      app/controllers/bulk_upload_lettings_resume_controller.rb
  2. 6
      app/helpers/logs_helper.rb
  3. 2
      app/views/bulk_upload_lettings_resume/confirm.html.erb

6
app/controllers/bulk_upload_lettings_resume_controller.rb

@ -23,12 +23,6 @@ class BulkUploadLettingsResumeController < ApplicationController
end
end
def pluralize_logs_and_errors_warning(log_count, error_count)
is_or_are = log_count == 1 ? "is" : "are"
need_or_needs = error_count == 1 ? "needs" : "need"
"There #{is_or_are} #{view_context.pluralize(log_count, 'log')} in this bulk upload with #{view_context.pluralize(error_count, 'error')} that still #{need_or_needs} to be fixed after upload."
end
private
def form

6
app/helpers/logs_helper.rb

@ -38,4 +38,10 @@ module LogsHelper
when "lettings" then csv_download_lettings_logs_path(search:, codes_only:)
end
end
def pluralize_logs_and_errors_warning(log_count, error_count)
is_or_are = log_count == 1 ? "is" : "are"
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."
end
end

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

@ -7,7 +7,7 @@
<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>
<p class="govuk-body"><%= controller.pluralize_logs_and_errors_warning(@bulk_upload.logs.count, @bulk_upload.bulk_upload_errors.count) %> </p>
<p class="govuk-body"><%= pluralize_logs_and_errors_warning(@bulk_upload.logs.count, @bulk_upload.bulk_upload_errors.count) %> </p>
<%= govuk_warning_text(icon_fallback_text: "Danger") do %>
You can not delete logs once you create them

Loading…
Cancel
Save