Browse Source

pluralize and return early

pull/1035/head
Kat 4 years ago
parent
commit
9bcde1b13a
  1. 3
      app/helpers/unresolved_log_helper.rb
  2. 32
      app/models/form.rb
  3. 4
      app/views/logs/index.html.erb

3
app/helpers/unresolved_log_helper.rb

@ -1,6 +1,7 @@
module UnresolvedLogHelper module UnresolvedLogHelper
def flash_notice_for_resolved_logs(count) def flash_notice_for_resolved_logs(count)
notice_message = "You’ve updated all the fields affected by the scheme change.</br>" notice_message = "You’ve updated all the fields affected by the scheme change.</br>"
notice_message << " <a href=\"/lettings-logs/update-logs\">Update #{count} more logs</a>" if count.positive? notice_message << " <a href=\"/lettings-logs/update-logs\">Update #{count} more #{'log'.pluralize(count)}</a>" if count.positive?
notice_message
end end
end end

32
app/models/form.rb

@ -57,23 +57,21 @@ class Form
end end
def next_page(page, log, current_user) def next_page(page, log, current_user)
if log.unresolved return page.next_unresolved_page_id || :check_answers if log.unresolved?
page.next_unresolved_page_id || :check_answers
else page_ids = subsection_for_page(page).pages.map(&:id)
page_ids = subsection_for_page(page).pages.map(&:id) page_index = page_ids.index(page.id)
page_index = page_ids.index(page.id) page_id = if page.id.include?("value_check") && log[page.questions[0].id] == 1 && page.routed_to?(log, current_user)
page_id = if page.id.include?("value_check") && log[page.questions[0].id] == 1 && page.routed_to?(log, current_user) previous_page(page_ids, page_index, log, current_user)
previous_page(page_ids, page_index, log, current_user) else
else page_ids[page_index + 1]
page_ids[page_index + 1] end
end nxt_page = get_page(page_id)
nxt_page = get_page(page_id)
return :check_answers if nxt_page.nil?
return :check_answers if nxt_page.nil? return nxt_page.id if nxt_page.routed_to?(log, current_user)
return nxt_page.id if nxt_page.routed_to?(log, current_user)
next_page(nxt_page, log, current_user)
next_page(nxt_page, log, current_user)
end
end end
def next_page_redirect_path(page, log, current_user) def next_page_redirect_path(page, log, current_user)

4
app/views/logs/index.html.erb

@ -10,9 +10,9 @@
title_heading_level: 3, title_heading_level: 3,
title_id: "impacted-logs-banner", title_id: "impacted-logs-banner",
) do |notification_banner| %> ) do |notification_banner| %>
<% notification_banner.heading(text: "A scheme has changed and it has affected #{@unresolved_count} #{@unresolved_count > 1 ? 'logs' : 'log'}") %> <% notification_banner.heading(text: "A scheme has changed and it has affected #{@unresolved_count} #{'log'.pluralize(@unresolved_count)}") %>
<div class="govuk-notification-banner__heading"> <div class="govuk-notification-banner__heading">
<a class="govuk-notification-banner__link" href=<%= update_logs_lettings_logs_path %>>Update logs</a> <a class="govuk-notification-banner__link" href="<%= update_logs_lettings_logs_path %>">Update logs</a>
</div> </div>
<% end %> <% end %>
<% end %> <% end %>

Loading…
Cancel
Save