-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AP-5424: Get check capital answers page working
- Loading branch information
Showing
5 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module CapitalDisregardHelper | ||
def mandatory_capital_disregards_list(legal_aid_application) | ||
mandatory_capital_disregards_names = legal_aid_application | ||
.mandatory_capital_disregards | ||
.pluck(:name).map do |key| | ||
I18n.t("providers.means.capital_disregards.mandatory.#{key}") | ||
end | ||
mandatory_capital_disregards_names.join("<br>").html_safe | ||
end | ||
|
||
def discretionary_capital_disregards_list(legal_aid_application) | ||
discretionary_capital_disregards_list = legal_aid_application | ||
.discretionary_capital_disregards | ||
.pluck(:name).map do |key| | ||
I18n.t("providers.means.capital_disregards.discretionary.#{key}") | ||
end | ||
discretionary_capital_disregards_list.join("<br>").html_safe | ||
end | ||
|
||
def amount_and_date_received(capital_disregard) | ||
"#{gds_number_to_currency(capital_disregard.amount)} on #{capital_disregard.date_received}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
app/views/shared/check_answers/_capital_disregard_details.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<% capital_disregard_type = capital_disregard.mandatory? ? 'mandatory' : 'discretionary' %> | ||
<% capital_disregard_name = t("providers.means.capital_disregards.#{capital_disregard_type}.#{capital_disregard.name}") %> | ||
|
||
<%= govuk_summary_list( | ||
actions: !read_only, | ||
classes: "govuk-!-margin-bottom-9", | ||
html_attributes: { id: "capital-disregard-questions_#{index}" }, | ||
) do |summary_list| %> | ||
|
||
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__capital_disregard_#{index}_change_link" }) do |row| %> | ||
<%= row.with_key(text: t(".#{capital_disregard_type}.heading", count: index + 1), classes: "govuk-!-width-one-half govuk-heading-m") %> | ||
<%= row.with_value(text: nil) %> | ||
<%= row.with_action( | ||
text: t("generic.change"), | ||
href: providers_legal_aid_application_means_capital_disregards_add_detail_path(@legal_aid_application, capital_disregard), | ||
visually_hidden_text: capital_disregard_name, | ||
) %> | ||
<% end %> | ||
|
||
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__payment_type" }) do |row| %> | ||
<%= row.with_key(text: t(".questions.payment_type"), classes: "govuk-!-width-one-half") %> | ||
<%= row.with_value { capital_disregard_name } %> | ||
<% end %> | ||
|
||
<% if capital_disregard.payment_reason.present? %> | ||
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__payment_reason" }) do |row| %> | ||
<%= row.with_key(text: t(".questions.payment_reason"), classes: "govuk-!-width-one-half") %> | ||
<%= row.with_value { capital_disregard.payment_reason } %> | ||
<% end %> | ||
<% end %> | ||
|
||
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__amount_and_date_received" }) do |row| %> | ||
<%= row.with_key(text: t(".questions.amount_and_date_received"), classes: "govuk-!-width-one-half") %> | ||
<%= row.with_value { amount_and_date_received(capital_disregard) } %> | ||
<% end %> | ||
|
||
<%= summary_list.with_row(html_attributes: { id: "app-check-your-answers__bank_account_name" }) do |row| %> | ||
<%= row.with_key(text: t(".questions.bank_account_name"), classes: "govuk-!-width-one-half") %> | ||
<%= row.with_value { capital_disregard.account_name } %> | ||
<% end %> | ||
<% end %> |
35 changes: 35 additions & 0 deletions
35
app/views/shared/check_answers/_capital_disregards.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<h2 class="govuk-heading-m"><%= t(".heading#{individual}") %></h2> | ||
<%= govuk_summary_list(classes: "govuk-!-margin-bottom-9", html_attributes: { id: "capital-disregards-questions" }) do |summary_list| %> | ||
|
||
<%= summary_list.with_row(html_attributes: { id: "app-check-your-mandatory_capital_disregards" }) do |row| %> | ||
<%= row.with_key(text: t(".mandatory_capital_disregards.key"), classes: "govuk-!-width-one-half") %> | ||
<%= row.with_value { @legal_aid_application.mandatory_capital_disregards.any? ? mandatory_capital_disregards_list(@legal_aid_application) : t("generic.none") } %> | ||
<% unless read_only %> | ||
<%= row.with_action( | ||
text: t("generic.change"), | ||
href: check_answer_url_for(journey_type, :capital_disregards_mandatory, @legal_aid_application), | ||
visually_hidden_text: t(".mandatory_capital_disregards.key"), | ||
) %> | ||
<% end %> | ||
<% end %> | ||
|
||
<%= summary_list.with_row(html_attributes: { id: "app-check-your-discretionary_capital_disregards" }) do |row| %> | ||
<%= row.with_key(text: t(".discretionary_capital_disregards.key"), classes: "govuk-!-width-one-half") %> | ||
<%= row.with_value { @legal_aid_application.discretionary_capital_disregards.any? ? discretionary_capital_disregards_list(@legal_aid_application) : t("generic.none") } %> | ||
<% unless read_only %> | ||
<%= row.with_action( | ||
text: t("generic.change"), | ||
href: check_answer_url_for(journey_type, :capital_disregards_discretionary, @legal_aid_application), | ||
visually_hidden_text: t(".discretionary_capital_disregards.key"), | ||
) %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
|
||
<% @legal_aid_application.mandatory_capital_disregards.each_with_index do |capital_disregard, index| %> | ||
<%= render("shared/check_answers/capital_disregard_details", capital_disregard:, index:, read_only:) %> | ||
<% end %> | ||
|
||
<% @legal_aid_application.discretionary_capital_disregards.each_with_index do |capital_disregard, index| %> | ||
<%= render("shared/check_answers/capital_disregard_details", capital_disregard:, index:, read_only:) %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters