ministryofjustice/Claim-for-Crown-Court-Defence

View on GitHub
app/views/case_workers/admin/allocations/_re_allocation.html.haml

Summary

Maintainability
Test Coverage
= render partial: 'layouts/header', locals: { page_heading: t('.page_heading') }

.govuk-grid-row
  .govuk-grid-column-full

    .govuk-grid-row
      .govuk-grid-column-two-thirds
        = govuk_error_summary(@allocation, :allocation)

    = form_with url: case_workers_admin_allocations_path, method: :get, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f|
      = render partial: 'orig_scheme_filters', locals: { f: f }

      = render partial: 'shared/search_form', locals: { search_path: case_workers_admin_allocations_path(anchor: 'search-button'), hint_text: t('hint.search'), button_text: t('search.claims') }

    = form_with model: [:case_workers, :admin, @allocation], builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f|
      = hidden_field_tag :scheme, params[:scheme]
      = hidden_field_tag :page, params[:page]

      .govuk-grid-row
        .govuk-grid-column-two-thirds
          = f.govuk_radio_buttons_fieldset :deallocate, legend: { text: t('.legend'), size: 'm' }, hint: { text: t('.form_hint_html') } do
            = f.govuk_radio_button :deallocate, 'true', label: { text: t('.allocation_pool') }, link_errors: true
            = f.govuk_radio_button :deallocate, 'false', label: { text: t('.case_worker') } do
              #cc-caseworker.fx-autocomplete-wrapper
                = f.govuk_select :case_worker_id, label: { text: t('.case_worker_name') } do
                  = options_for_select [['', '']]
                  = options_from_collection_for_select @case_workers, :id, :name

          = f.govuk_submit t('.re_allocate'), name: 'tab', value: 'allocated'

      - if @claims.any?
        = govuk_table(class: 'js-checkbox-table') do
          = govuk_table_caption(id: 'allocation-claim-ids-field-error') do
            .govuk-grid-row
              .govuk-grid-column-one-half
                = t('.re_allocation')
              .govuk-grid-column-one-half.claim-count{ class: 'govuk-!-text-align-right' }
                = t('.number_of_claims', claim_count: @claims.total_count)

          = govuk_table_thead do
            = govuk_table_row do
              = govuk_table_th do
                = govuk_link_to t('.select_all'), '#', class: 'select-all', data: { 'all-checked': 'false' }, 'aria-label': t('.select_all_label')
              = govuk_table_th do
                = t('.case_number')
              = govuk_table_th do
                = t('.court')
              = govuk_table_th do
                = t('.defendants')
              = govuk_table_th do
                = t('.type')
              = govuk_table_th_numeric do
                = t('.submitted_date')
              = govuk_table_th_numeric do
                = t('.claim_total')
              - if params[:tab] == 'allocated'
                = govuk_table_th do
                  = t('.allocated_to')

          = govuk_table_tbody do
            = collection_check_boxes :allocation, :claim_ids, @claims, :id, :case_number do |b|
              - present(b.object) do |claim|
                = govuk_table_row(id: dom_id(claim), class: claim.injection_error ? 'error injection-error' : nil) do
                  = govuk_table_td('data-label': t('.select')) do
                    .govuk-form-group.error-message-container
                      .govuk-checkboxes.govuk-checkboxes--small{ 'data-module': 'govuk-checkboxes' }
                        .govuk-checkboxes__item
                          = b.check_box(class: 'govuk-checkboxes__input')
                          = b.label(class: 'govuk-label govuk-checkboxes__label'){ t('.choose_label_html', case_number: claim.case_number) }

                      - claim.injection_error do |message|
                        .error-message
                          = message

                  = govuk_table_td('data-label': t('.case_number')) do
                    %span.js-test-case-number
                      = govuk_link_to claim.case_number, case_workers_claim_path(claim), 'aria-label': t('.case_number_label', case_number: claim.case_number)
                      %span.unique-id-small
                        = claim.unique_id
                      - if claim.disk_evidence == true
                        %span.disk-evidence
                          = t('.disk_evidence')

                  = govuk_table_td('data-label': t('.court')) do
                    = claim.court.name

                  = govuk_table_td('data-label': t('.defendants')) do
                    = claim.defendant_names

                  = govuk_table_td('data-label': t('.type')) do
                    = claim.case_type_name
                    %br/
                    %span.claim-state
                      = claim.claim_state

                  = govuk_table_td_numeric('data-label': t('.submitted_date')) do
                    = claim.submitted_at_short

                  = govuk_table_td_numeric('data-label': t('.claim_total')) do
                    = claim.total_inc_vat

                  - if params[:tab] == 'allocated'
                    = govuk_table_td('data-label': t('.allocated_to')) do
                      = claim.case_workers.map(&:name).join(', ')

      - else
        %p.govuk-body{ class: 'govuk-!-font-weight-bold' }
          = t('.no_claims_allocated')