ministryofjustice/Claim-for-Crown-Court-Defence

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

Summary

Maintainability
Test Coverage
.nested-fields.resource-details.defendant-details.fx-numberedList-item

  = f.govuk_fieldset legend: { text: t('.defendant_html') } do

    = link_to_remove_association f, class: 'govuk-link govuk-!-display-none fx-numberedList-action' do
      = t('common.remove_html', context: t('.defendant'))

    - @representation_order_count = 0

    = f.govuk_text_field :first_name,
      form_group: { class: 'cc-first-name' },
      label: { text: t('.first_name_html') },
      width: 'one-half'

    = f.govuk_text_field :last_name,
      form_group: { class: 'cc-last-name' },
      label: { text: t('.last_name_html') },
      width: 'one-half'

    = f.govuk_date_field :date_of_birth,
      date_of_birth: true,
      form_group: { class: 'cc-dob', id: "defendant_#{@defendant_count+1}_date_of_birth_group" },
      hint: { text: t('.date_hint') },
      legend: { text: t('.date_of_birth_html'), size: 's' },
      maxlength_enabled: true

    - unless @claim.lgfs? && @claim.interim?
      = f.govuk_check_box :order_for_judicial_apportionment,
        1,
        0,
        label: { text: t('.order_for_judicial_apportionment_html') },
        link_errors: true,
        multiple: false

      = govuk_detail 'Help with judicial apportionment' do
        = t('.order_for_judicial_apportionment_help')

    - unless f.object.representation_orders.any?
      - f.object.representation_orders << RepresentationOrder.new

    .documents.fx-numberedList-item_
      = f.fields_for :representation_orders do |repo_form|
        = render partial: 'external_users/claims/defendants/representation_order_fields', locals: { f: repo_form }
    .links
      = link_to_add_association t('.add_another_rep_order'), f, :representation_orders, partial: 'external_users/claims/defendants/representation_order_fields'

  - @defendant_count += 1