Skip to content

Commit

Permalink
Wrap defendent details in summary card. Replace name with first name …
Browse files Browse the repository at this point in the history
…and last name
  • Loading branch information
Katy600 committed Nov 28, 2024
1 parent 19f3761 commit 9cf7915
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 41 deletions.
2 changes: 2 additions & 0 deletions app/models/defendant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Defendant < ApplicationRecord

accepts_nested_attributes_for :representation_orders, reject_if: :all_blank, allow_destroy: true

# Do we still need this name method now we are using first name
# and last name on the summary page instead?
def name
[first_name, last_name].join(' ').gsub(' ', ' ')
end
Expand Down
8 changes: 3 additions & 5 deletions app/views/shared/_claim.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,10 @@
= claim.main_hearing_date&.strftime(Settings.date_format)

- if claim.defendants.any?
.govuk-grid-row
.govuk-grid-column-two-thirds
%h3.govuk-heading-m
= t('.defendants')
%h2.govuk-heading-l
= t('external_users.claims.defendants.defendant_fields.defendant_details')

= render partial: 'shared/claim_defendants', locals: {defendants: claim.defendants }
= render partial: 'shared/claim_defendants', locals: {defendants: claim.defendants }

- else
.govuk-grid-row
Expand Down
77 changes: 44 additions & 33 deletions app/views/shared/_claim_defendant_details.html.haml
Original file line number Diff line number Diff line change
@@ -1,33 +1,44 @@
.app-card--defendant
%h4.govuk-heading-s
= t('.defendant', context: index)

= govuk_summary_list do
= govuk_summary_list_row_collection( t('external_users.claims.defendants.defendant_fields.full_name') ) { defendant.name }

- if defendant.date_of_birth.present?
= govuk_summary_list_row_collection( t('external_users.claims.defendants.defendant_fields.date_of_birth') ) { defendant.date_of_birth.strftime(Settings.date_format) rescue '' }

- unless @claim.lgfs? && @claim.interim?
= govuk_summary_list_row_collection( t('external_users.claims.defendants.defendant_fields.judical_apportionment') ) { defendant.order_for_judicial_apportionment == true ? t('global_yes') : t('global_no') }


- if defendant.representation_orders.any?
= govuk_table do
= govuk_table_caption do
= t('shared.claim.reporders')

= govuk_table_thead_collection [t('.date'),
t('external_users.claims.defendants.representation_order_fields.maat_reference_number')]

= govuk_table_tbody do
- defendant.representation_orders.each do | representation_order |
= govuk_table_row do
= govuk_table_td('data-label': t('.date')) do
= representation_order.representation_order_date.strftime(Settings.date_format) rescue ''

= govuk_table_td('data-label': t('external_users.claims.defendants.representation_order_fields.maat_reference_number')) do
= representation_order.maat_reference

- else
= govuk_inset_text(t('.no_reporder'))
.govuk-summary-card
.govuk-summary-card__title-wrapper
%h2.govuk-summary-card__title
= t('.defendant', context: index)

.govuk-summary-card__content
%dl.govuk-summary-list
.govuk-summary-list__row.summary-page-table-two-row
%dt.govuk-summary-list__key
= t('external_users.claims.defendants.defendant_fields.first_name')
%dd.govuk-summary-list__value
= defendant.first_name

.govuk-summary-list__row.summary-page-table-two-row
%dt.govuk-summary-list__key
= t('external_users.claims.defendants.defendant_fields.last_name')
%dd.govuk-summary-list__value
= defendant.last_name

.govuk-summary-list__row.summary-page-table-two-row
%dt.govuk-summary-list__key
= t('external_users.claims.defendants.defendant_fields.date_of_birth')
%dd.govuk-summary-list__value
= defendant.date_of_birth.strftime(Settings.date_format) rescue ''

.govuk-summary-list__row.summary-page-table-two-row
%dt.govuk-summary-list__key
= t('external_users.claims.defendants.defendant_fields.order_of_judicial_apportionment')
%dd.govuk-summary-list__value
= defendant.order_for_judicial_apportionment == true ? t('global_yes') : t('global_no')

- if defendant.representation_orders.any?
.govuk-summary-list__row.summary-page-table-two-row
%dt.govuk-summary-list__key
- defendant.representation_orders.each_with_index do |representation_order, index|
= "#{t('shared.claim.reporders')} #{index + 1}"

%dd.govuk-summary-list__value.summary-page-values
%span #{representation_order.representation_order_date.strftime(Settings.date_format) rescue ''}
%span
= t('external_users.claims.defendants.defendant_fields.maat_reference')
#{representation_order.maat_reference }
- else
= govuk_inset_text(t('.no_reporder'))
1 change: 0 additions & 1 deletion app/views/shared/_claim_defendants.html.haml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
- defendants.each_with_index do | defendant, index |
.govuk-grid-column-one-half
= render partial: 'shared/claim_defendant_details', locals: { defendant: present(defendant, CaseWorkers::DefendantPresenter), index: index += 1 }
5 changes: 5 additions & 0 deletions app/webpack/stylesheets/_shame.scss
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,11 @@ form {
text-align: right;
}

.summary-page-values {
display: flex;
flex-direction: column;
}

.download-all-link {
display: inline-block;
margin-top: 20px;
Expand Down
6 changes: 4 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1175,20 +1175,22 @@ en:
selected_offence_header: 'You have chosen the following offence details:'
defendants:
defendant_fields:
defendant_details: Defendant details
first_name: *first_name
first_name_html: First name <span class="govuk-visually-hidden">for defendant <span class="fx-numberedList-number"></span></span>
last_name: *last_name
last_name_html: Last name <span class="govuk-visually-hidden">for defendant <span class="fx-numberedList-number"></span></span>
full_name: Full name
date_of_birth: Date of birth
date_of_birth_html: Date of birth <span class="govuk-visually-hidden">for defendant <span class="fx-numberedList-number"></span></span>
date_hint: *date_hint
judical_apportionment: Judicial apportionment
order_of_judicial_apportionment: Order for judicial apportionment
order_for_judicial_apportionment: Order for judicial apportionment
order_for_judicial_apportionment_html: Order for judicial apportionment <span class="govuk-visually-hidden">for defendant <span class="fx-numberedList-number"></span></span>
order_for_judicial_apportionment_help: Judicial apportionment is when the defendant has applied for and received an order confirming they are not required to pay the full amount of their defence costs. If applicable, ensure you upload a copy of the order to your claim.
add_another_rep_order: 'Add another representation order'
remove_defendant: 'Remove defendant'
maat_reference: 'MAAT reference:'
defendant: Defendant
defendant_html: Defendant <span class="fx-numberedList-number"></span>
remove: Remove
Expand Down Expand Up @@ -2093,7 +2095,6 @@ en:
case_worker: Case worker
claim_type: Claim and case type
defendant: Defendant names
defendants: Defendants
j_a: Judicial apportionment
no_defendant: No defendant details have been supplied for this claim
offence: Offence
Expand Down Expand Up @@ -2431,6 +2432,7 @@ en:
additional_information: Additional claim information
created_by: 'Created by:'
h2_basic_info: Basic claim information
h2_defendant_details: Defendant
h2_evidence: Evidence
h2_messages: Messages and claim status
h2_status: Status
Expand Down
1 change: 1 addition & 0 deletions spec/models/defendant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
context 'name presentation methods' do
let(:claim) { create(:advocate_claim) }

# Do we still need this now we aren't using it on the summary page?
describe '#name' do
it 'joins first name and last name together' do
defendant = create(:defendant, first_name: 'Roberto', last_name: 'Smith', claim_id: claim.id)
Expand Down

0 comments on commit 9cf7915

Please sign in to comment.