Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ctskf 473 cccd consolidate evidence table on summary page #7684

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/models/document.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class Document < ApplicationRecord
include Duplicable
include ActionView::Helpers::NumberHelper

belongs_to :external_user
belongs_to :creator, class_name: 'ExternalUser'
Expand Down Expand Up @@ -63,6 +64,14 @@ def document_file_size
document.byte_size if document.attached?
end

def document_file_size_in_kb
number_to_human_size(document.byte_size) if document.attached?
end

def document_date_added
document.created_at.strftime('%m/%d/%y')
end

private

def documents_count
Expand Down
2 changes: 1 addition & 1 deletion app/validators/representation_order_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def post_agfs_reform?
end

def earliest_permitted
if claim&.lgfs? && claim&.interim?
if claim.lgfs? && claim.interim?
{ date: Settings.interim_earliest_permitted_repo_date, error: :not_before_interim_earliest_permitted_date }
else
{ date: Settings.earliest_permitted_date, error: :not_before_earliest_permitted_date }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,11 @@
- if local_assigns[:editable]
= govuk_link_to t('common.change_html', context: t('external_users.claims.supporting_evidence_checklist.summary.header')), edit_polymorphic_path(claim, step: :supporting_evidence, referrer: :summary), class: 'govuk-!-static-margin-bottom-7 link-change'

- if claim.mandatory_supporting_evidence?
= govuk_summary_list do
= govuk_summary_list_row_collection( t('shared.summary.disk_evidence') ) { claim.disk_evidence ? t('.answer_yes') : t('.answer_no') }
= govuk_summary_list_row_collection( t('shared.summary.disk_evidence_reference') ) { claim.disk_evidence_reference }

= govuk_summary_list_row_collection( t('shared.summary.supporting_evidence') ) do
%ul.govuk-list
- claim.documents.includes(:document_blob, :converted_preview_document_attachment).each do |document|
%li
= govuk_link_to document.document_file_name,
download_document_path(document),
class: 'download',
'aria-label': "Download document: #{document.document_file_name}"
- unless @claim.evidence_checklist_ids.empty?
= render partial: 'shared/supporting_evidence_checklist', locals: { f: @claim }

= govuk_summary_list_row_collection( t('shared.summary.supporting_evidence_checklist') ) do
%ul.govuk-list
- DocType.find_by_ids(claim.evidence_checklist_ids).each do |dt|
%li
= dt.name

- if claim.additional_information.present?
= govuk_summary_list_row_collection( t('external_users.claims.additional_information.summary.header') ) { format_multiline(claim.additional_information) }
- if claim.mandatory_supporting_evidence?
= render partial: 'shared/supporting_evidence_uploads', locals: {f: @claim }

- else
- if local_assigns.has_key?(:editable) && !local_assigns[:editable]
Expand Down
1 change: 1 addition & 0 deletions app/views/shared/_claim_accordion.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
%h2.govuk-heading-l
= t('.h2_evidence')
.js-accordion__panel
= render partial: 'shared/evidence_checklist'
= render partial: 'shared/evidence_list'

%h2.govuk-heading-l
Expand Down
20 changes: 4 additions & 16 deletions app/views/shared/_evidence_checklist.html.haml
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
.evidence-checklist-read-only
- if @claim.disk_evidence?
- if @claim.disk_evidence?
.evidence-checklist-read-only
%h3.govuk-heading-m
= t('.evidence_address')
= render partial: 'external_users/claims/supporting_documents/laa_address', locals: { f: @claim }

%h3.govuk-heading-m
= t('shared.evidence_checklist.caption')
- if current_user.persona.is_a? ExternalUser
%p.form-hint
= t('.evidence_hint')

- if @claim.evidence_checklist_ids.empty?
%p
= t('.no_evidence')
- else
%ul.govuk-list
- DocType.find_by_ids(@claim.evidence_checklist_ids).each do |dt|
%li
= dt.name
- unless @claim.evidence_checklist_ids.empty?
= render partial: 'shared/supporting_evidence_checklist', locals: { f: @claim }
44 changes: 2 additions & 42 deletions app/views/shared/_evidence_list.html.haml
Original file line number Diff line number Diff line change
@@ -1,50 +1,10 @@
= 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')
= t('shared.evidence_list.no_supporting_evidence')

- 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)
= render partial: 'shared/supporting_evidence_uploads', locals: {f: @claim }
10 changes: 10 additions & 0 deletions app/views/shared/_supporting_evidence_checklist.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.div.govuk-summary-card
.govuk-summary-card__title-wrapper
%h2.govuk-summary-card__title= (t('shared.summary.supporting_evidence_checklist'))
.govuk-summary-card__content
%dl.govuk-summary-list
= govuk_summary_list do
%ul.remove-margin
- DocType.find_by_ids(@claim.evidence_checklist_ids).each do |dt|
%li.no-bullets-item.format-supporting-evidence-list
= dt.name
16 changes: 16 additions & 0 deletions app/views/shared/_supporting_evidence_uploads.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.govuk-summary-card.custom-summary-card
.govuk-summary-card__title-wrapper
%h2.govuk-summary-card__title= (t('shared.evidence_list.existing_evidence'))
.govuk-summary-card__content
%dl.govuk-summary-list
%div.govuk-summary-list__row
%div.govuk-summary-list__key.file-name= (t('shared.evidence_list.file'))
%div.govuk-summary-list__key.file-info= (t('shared.evidence_list.file_size'))
%div.govuk-summary-list__key.file-info= (t('shared.evidence_list.date_added'))

- @claim.documents.includes(:document_blob, :converted_preview_document_attachment).each do |document|
%div.govuk-summary-list__row
%div.govuk-summary-list__value.file-name= govuk_link_to document.document_file_name, download_document_path(document)
%div.govuk-summary-list__value.file-info= document.document_file_size_in_kb
%div.govuk-summary-list__value.file-info= document.document_date_added

39 changes: 39 additions & 0 deletions app/webpack/stylesheets/_shame.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,45 @@
}
}

// Formats the row length of the 'Existing evidence' table
.custom-summary-card .govuk-summary-list__row {
display: flex;
}

.custom-summary-card .govuk-summary-list__key.file-name,
.custom-summary-card .govuk-summary-list__value.file-name {
flex: 3;
text-align: left;
}

.custom-summary-card .govuk-summary-list__key.file-info,
.custom-summary-card .govuk-summary-list__value.file-info {
flex: 1;
text-align: right;
}

.format-supporting-evidence-list {
margin-left: 0;
padding-top: 0;
padding-left: 10px;
list-style-type: none;
}

.download-all-link {
display: inline-block;
margin-top: 20px;
margin-right: 20px;
margin-bottom: 10px;
}

.no-bullets-item {
list-style-type: none;
}

.remove-margin {
margin: 0;
}

#claims-list>li {
padding: 1rem;
clear: both;
Expand Down
7 changes: 4 additions & 3 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2171,8 +2171,9 @@ en:
caption: 'Evidence Provided: A list of uploaded documents'
summary: 'Note: View and Download links are in 4th column, Actions'
existing_evidence: Existing evidence
no_documents_uploaded: No documents have been uploaded.
name_of_file: Name of file
download_all: Download all
no_supporting_evidence: There is no supporting evidence for this claim
file: File
file_size: File size
date_added: Date added
actions: Actions
Expand Down Expand Up @@ -2430,7 +2431,7 @@ en:
additional_information: Additional claim information
created_by: 'Created by:'
h2_basic_info: Basic claim information
h2_evidence: Evidence
h2_evidence: Supporting evidence
h2_messages: Messages and claim status
h2_status: Status
h2_summary: Fees, expenses and more information
Expand Down
2 changes: 1 addition & 1 deletion spec/models/claims/cloner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def create_rejected_claim

def representation_orders_for(defendants)
[].tap do |collection|
defendants.each { |d| collection << d.representation_orders }
defendants.map { |d| collection << d.representation_orders }
end.flatten
end
end