Browse Source

feat: fix subsection count bug

pull/1509/head
natdeanlewissoftwire 3 years ago
parent
commit
da1100ec12
  1. 2
      app/helpers/tasklist_helper.rb
  2. 2
      app/models/form/sales/subsections/discounted_ownership_scheme.rb
  3. 2
      app/models/form/sales/subsections/outright_sale.rb
  4. 2
      app/models/form/sales/subsections/shared_ownership_scheme.rb
  5. 2
      app/views/logs/edit.html.erb

2
app/helpers/tasklist_helper.rb

@ -6,7 +6,7 @@ module TasklistHelper
end
def get_subsections_count(log, status = :all)
return log.form.subsections.count { |subsection| subsection.applicable_questions(log).count.positive? } if status == :all
return log.form.subsections.count { |subsection| subsection.displayed_in_tasklist?(log) } if status == :all
log.form.subsections.count { |subsection| subsection.status(log) == status && subsection.applicable_questions(log).count.positive? }
end

2
app/models/form/sales/subsections/discounted_ownership_scheme.rb

@ -41,6 +41,6 @@ class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection
end
def displayed_in_tasklist?(log)
log.ownershipsch == 2
log.ownershipsch.nil? || log.ownershipsch == 2
end
end

2
app/models/form/sales/subsections/outright_sale.rb

@ -26,7 +26,7 @@ class Form::Sales::Subsections::OutrightSale < ::Form::Subsection
end
def displayed_in_tasklist?(log)
log.ownershipsch == 3
log.ownershipsch.nil? || log.ownershipsch == 3
end
def leasehold_charge_pages

2
app/models/form/sales/subsections/shared_ownership_scheme.rb

@ -46,6 +46,6 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection
end
def displayed_in_tasklist?(log)
log.ownershipsch == 1
log.ownershipsch.nil? || log.ownershipsch == 1
end
end

2
app/views/logs/edit.html.erb

@ -11,7 +11,7 @@
</h1>
<% if @log.status == "in_progress" %>
<p class="govuk-body govuk-!-margin-bottom-7"><%= get_subsections_count(@log, :completed) %> of <%= get_subsections_count(@log, :all) %> sections completed.</p>
<p class="govuk-body govuk-!-margin-bottom-7"><%= get_subsections_count(@log, :completed) %> of <%= get_subsections_count(@log, :all) %> subsections completed.</p>
<p class="govuk-body govuk-!-margin-bottom-2">
<% next_incomplete_section = get_next_incomplete_section(@log) %>
</p>

Loading…
Cancel
Save