ministryofjustice/Claim-for-Crown-Court-Defence

View on GitHub
app/views/external_users/claims/defendants/_summary.html.haml

Summary

Maintainability
Test Coverage
#defendants-section.app-summary-section
  %h2.govuk-heading-l
    = t('external_users.claims.defendants.summary.header')

  - if local_assigns[:editable]
    = govuk_link_to t('common.change_html', context: t('external_users.claims.defendants.summary.header')), edit_polymorphic_path(claim, step: :defendants, referrer: :summary), class: 'link-change'

  - defendant_fields_scope = 'external_users.claims.defendants.defendant_fields'
  - rep_order_fields_scope = 'external_users.claims.defendants.representation_order_fields'

  - if claim.defendants.empty?
    - if local_assigns.has_key?(:editable) && !local_assigns[:editable]
      = render partial: 'external_users/claims/summary/section_status', locals: { claim: claim, section: section, step: :defendants }
    - else
      %p
        = t('shared.summary.no_values.defendants')
  - else
    - claim.defendants.order(:created_at).each.with_index(1) do | defendant, index|

      - if claim.defendants.count > 1
        %h3.govuk-heading-m
          = t('.common.defendant_index', index: index)

      = govuk_summary_list do
        = govuk_summary_list_row_collection( t('first_name', scope: defendant_fields_scope) ) { defendant.first_name }
        = govuk_summary_list_row_collection( t('last_name', scope: defendant_fields_scope) ) { defendant.last_name }

        - if defendant.date_of_birth.present?
          = govuk_summary_list_row_collection( t('date_of_birth', scope: defendant_fields_scope) ) do
            %time{ 'aria-label': defendant.date_of_birth.strftime(Settings.date_format_label), datetime: defendant.date_of_birth.strftime(Settings.datetime_attribute) }
              = defendant.date_of_birth.strftime(Settings.date_format)

        - unless claim.lgfs? && claim.interim?
          = govuk_summary_list_row_collection( t('order_for_judicial_apportionment', scope: defendant_fields_scope) ) { defendant.order_for_judicial_apportionment == true ? t('.answer_yes') : t('.answer_no') }

        - defendant.representation_orders.each.with_index(1) do | representation_order, index|
          = govuk_summary_list_row_collection( t('date', scope: rep_order_fields_scope) ) do
            %time{ 'aria-label': representation_order.representation_order_date.strftime(Settings.date_format_label), datetime: representation_order.representation_order_date.strftime(Settings.datetime_attribute) }
              = representation_order.representation_order_date.strftime(Settings.date_format)

          = govuk_summary_list_row_collection( t('maat_reference_number', scope: rep_order_fields_scope) ) { representation_order.maat_reference }