ministryofjustice/Claim-for-Crown-Court-Defence

View on GitHub
app/views/shared/_evidence_list.html.haml

Summary

Maintainability
Test Coverage
= render partial: 'shared/evidence_checklist'

.app-summary-section
  %h3.govuk-heading-m
    = t('.existing_evidence')

  - if current_user_persona_is?(CaseWorker) && @claim.documents.any?
    = govuk_link_to t('shared.download_all_html', context: t('.existing_evidence')), download_zip_case_workers_claim_path(@claim), class: 'download-all-link'

  - if @claim.documents.none?
    %p.govuk-body
      = t('.no_documents_uploaded')

  - else
    = govuk_table do
      = govuk_table_caption(class: 'govuk-visually-hidden') do
        = t('.caption')

      = govuk_table_thead do
        = govuk_table_row do
          = govuk_table_th do
            = t('.name_of_file')

          = govuk_table_th_numeric do
            = t('.file_size')

          = govuk_table_th_numeric do
            = t('.date_added')

          = govuk_table_th_numeric do
            = t('.actions')

      = govuk_table_tbody do
        - @claim.documents.includes(:document_blob, :converted_preview_document_attachment).each do |document|
          = govuk_table_row do
            = govuk_table_td('data-label': t('.name_of_file')) do
              = document.document_file_name

            = govuk_table_td_numeric('data-label': t('.file_size')) do
              = number_to_human_size(document.document_file_size)

            = govuk_table_td_numeric('data-label': t('.date_added')) do
              = document.created_at.strftime(Settings.date_format)

            = govuk_table_td_numeric('data-label': t('.actions')) do
              .app-link-group
                - if document.converted_preview_document.present?
                  = govuk_link_to t('common.view_html', context: "#{document.document_file_name}"), document_path(document)

                = govuk_link_to t('common.download_html', context: "#{document.document_file_name}"), download_document_path(document)