Browse Source

Hide section/subsections from task list

pull/2780/head
Manny Dinssa 9 months ago
parent
commit
0b5c7756df
  1. 9
      app/models/form/sales/subsections/household_needs.rb
  2. 9
      app/models/form/sales/subsections/household_situation.rb
  3. 8
      app/models/form/sales/subsections/income_benefits_and_savings.rb
  4. 5
      app/views/logs/_tasklist.html.erb

9
app/models/form/sales/subsections/household_needs.rb

@ -7,7 +7,7 @@ class Form::Sales::Subsections::HouseholdNeeds < ::Form::Subsection
def depends_on def depends_on
if form.start_year_2025_or_later? if form.start_year_2025_or_later?
[{ "setup_completed?" => true, "is_staircase?" => true }] [{ "setup_completed?" => true, "is_staircase?" => false }]
else else
[{ "setup_completed?" => true }] [{ "setup_completed?" => true }]
end end
@ -24,4 +24,11 @@ class Form::Sales::Subsections::HouseholdNeeds < ::Form::Subsection
Form::Sales::Pages::HouseholdWheelchairCheck.new("wheelchair_check", nil, self), Form::Sales::Pages::HouseholdWheelchairCheck.new("wheelchair_check", nil, self),
] ]
end end
def displayed_in_tasklist?(log)
return true unless form.start_year_2025_or_later?
log.staircase != 1
end
end end

9
app/models/form/sales/subsections/household_situation.rb

@ -7,7 +7,7 @@ class Form::Sales::Subsections::HouseholdSituation < ::Form::Subsection
def depends_on def depends_on
if form.start_year_2025_or_later? if form.start_year_2025_or_later?
[{ "setup_completed?" => true, "is_staircase?" => true }] [{ "setup_completed?" => true, "is_staircase?" => false }]
else else
[{ "setup_completed?" => true }] [{ "setup_completed?" => true }]
end end
@ -23,4 +23,11 @@ class Form::Sales::Subsections::HouseholdSituation < ::Form::Subsection
Form::Sales::Pages::Buyer2PreviousHousingSituation.new(nil, nil, self), Form::Sales::Pages::Buyer2PreviousHousingSituation.new(nil, nil, self),
].flatten.compact ].flatten.compact
end end
def displayed_in_tasklist?(log)
return true unless form.start_year_2025_or_later?
log.staircase != 1
end
end end

8
app/models/form/sales/subsections/income_benefits_and_savings.rb

@ -7,7 +7,7 @@ class Form::Sales::Subsections::IncomeBenefitsAndSavings < ::Form::Subsection
def depends_on def depends_on
if form.start_year_2025_or_later? if form.start_year_2025_or_later?
[{ "setup_completed?" => true, "is_staircase?" => true }] [{ "setup_completed?" => true, "is_staircase?" => false }]
else else
[{ "setup_completed?" => true }] [{ "setup_completed?" => true }]
end end
@ -43,6 +43,12 @@ class Form::Sales::Subsections::IncomeBenefitsAndSavings < ::Form::Subsection
].compact ].compact
end end
def displayed_in_tasklist?(log)
return true unless form.start_year_2025_or_later?
log.staircase != 1
end
private private
def previous_shared_page def previous_shared_page

5
app/views/logs/_tasklist.html.erb

@ -1,5 +1,6 @@
<ol class="app-task-list govuk-!-margin-top-8"> <ol class="app-task-list govuk-!-margin-top-8">
<% @log.form.sections.map do |section| %> <% @log.form.sections.each do |section| %>
<% next if section.subsections.none? { |subsection| subsection.displayed_in_tasklist?(@log) } %>
<li> <li>
<h2 class="app-task-list__section-heading"> <h2 class="app-task-list__section-heading">
<%= section.label %> <%= section.label %>
@ -8,7 +9,7 @@
<p class="govuk-body"><%= section.description.html_safe %></p> <p class="govuk-body"><%= section.description.html_safe %></p>
<% end %> <% end %>
<ul class="app-task-list__items"> <ul class="app-task-list__items">
<% section.subsections.map do |subsection| %> <% section.subsections.each do |subsection| %>
<% if subsection.displayed_in_tasklist?(@log) && (subsection.applicable_questions(@log).count > 0 || !subsection.enabled?(@log)) %> <% if subsection.displayed_in_tasklist?(@log) && (subsection.applicable_questions(@log).count > 0 || !subsection.enabled?(@log)) %>
<% subsection_status = subsection.status(@log) %> <% subsection_status = subsection.status(@log) %>
<li class="app-task-list__item"> <li class="app-task-list__item">

Loading…
Cancel
Save