Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP-5592: Update scope limits on check provider answers #7541

Merged
merged 5 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/assets/stylesheets/check-your-answers.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,7 @@
.print-no-break>.govuk-body {
word-wrap: break-word;
}

.single-scope-limit-heading {
font-weight: bold;
}
12 changes: 9 additions & 3 deletions app/helpers/proceeding_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ def scope_limits(proceeding, scope_type)
private

def scope_limitation_details(scope_limitation)
scope_limitation_details = [scope_limitation.meaning, scope_limitation.description]
sole_scope_limitation = scope_limitation.proceeding.scope_limitations.where(scope_type: scope_limitation.scope_type).count.eql?(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could extract to own method

def sole_scope_limitation?(scope_limitation)
  scope_limitation.proceeding.scope_limitations.where(scope_type: scope_limitation.scope_type).count.eql?(1)
end

scope_limitation_meaning = if sole_scope_limitation
scope_limitation.meaning
else
"<span class=\"single-scope-limit-heading\">#{scope_limitation.meaning}</span>".html_safe
end
scope_limitation_details = [scope_limitation_meaning, scope_limitation.description]
Comment on lines +25 to +30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another method extraction perhaps?

def scope_limitation_base_details(scope_limitation)
  scope_limitation_meaning = if sole_scope_limitation?(scope_limitation)
                               scope_limitation.meaning
                             else
                               "<span class=\"single-scope-limit-heading\">#{scope_limitation.meaning}</span>".html_safe
                             end
  [scope_limitation_meaning, scope_limitation.description]
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or extract both to a class nested in the helper?

like...

ScopeLimitationDetailBuilder.new(scope_limitation).call


if scope_limitation.hearing_date
scope_limitation_details << "Date: #{scope_limitation.hearing_date}"
if scope_limitation.hearing_date && scope_limitation.description.exclude?(scope_limitation.hearing_date.to_s)
scope_limitation_details[1] = "#{scope_limitation.description} #{scope_limitation.hearing_date}"
elsif scope_limitation.limitation_note
scope_limitation_details << "Note: #{scope_limitation.limitation_note}"
end
Expand Down
7 changes: 4 additions & 3 deletions app/views/shared/check_answers/_proceeding_details.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
unless @show_linked_proceedings || @read_only
govuk_link_to(t("generic.change"),
providers_legal_aid_application_client_involvement_type_path(@legal_aid_application, proceeding),
id: "app-check-your-answers__#{proceeding.ccms_code.downcase}",
visually_hidden_suffix: "#{proceeding.meaning} #{t('.description')}")
end
end

card.with_summary_list(actions: false) do |summary_list|
card.with_summary_list(actions: false, html_attributes: { id: "#{proceeding.ccms_code.downcase}-questions" }) do |summary_list|
summary_list.with_row(html_attributes: { id: "app-check-your-answers__#{proceeding.name}_client_involvement_type" }) do |row|
row.with_key(text: t(".client_involvement_type_details.question"), classes: "govuk-!-width-one-third")
row.with_value { proceeding.client_involvement_type_description }
Expand All @@ -34,7 +35,7 @@
end
end

summary_list.with_row(html_attributes: { id: "app-check-your-answers__#{proceeding.name}_emergency_scope_limitations_#{proceeding.id}" }) do |row|
summary_list.with_row(html_attributes: { id: "app-check-your-answers__#{proceeding.ccms_code.downcase}_emergency_scope_limitations" }) do |row|
row.with_key(text: t(".scope_limits.emergency.question"))
row.with_value { scope_limits(proceeding, "emergency") }
end
Expand All @@ -54,7 +55,7 @@
end
end

summary_list.with_row(html_attributes: { id: "app-check-your-answers__#{proceeding.name}_substantive_scope_limitations_#{proceeding.id}" }) do |row|
summary_list.with_row(html_attributes: { id: "app-check-your-answers__#{proceeding.ccms_code.downcase}_substantive_scope_limitations" }) do |row|
row.with_key(text: t(".scope_limits.substantive.question"))
row.with_value { scope_limits(proceeding, "substantive") }
end
Expand Down
Loading
Loading