From 0e74d00398385f7827482ba8945f8e8bb501af3c Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Tue, 2 Apr 2024 17:00:25 +0100 Subject: [PATCH] Show case number from MAAT Display the case number for a representation order taken from MAAT. As this is experimental it can be enabled or disabled by the user. --- .../case_workers/claims_controller.rb | 10 +++++ app/views/shared/_claim.html.haml | 7 +++- ...laim_defendant_details_with_maat.html.haml | 37 +++++++++++++++++++ app/views/shared/_claim_defendants.html.haml | 2 +- .../_claim_defendants_with_maat.html.haml | 3 ++ config/locales/en.yml | 10 +++++ 6 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 app/views/shared/_claim_defendant_details_with_maat.html.haml create mode 100644 app/views/shared/_claim_defendants_with_maat.html.haml diff --git a/app/controllers/case_workers/claims_controller.rb b/app/controllers/case_workers/claims_controller.rb index 6061416712..e71c0423b2 100644 --- a/app/controllers/case_workers/claims_controller.rb +++ b/app/controllers/case_workers/claims_controller.rb @@ -16,6 +16,7 @@ class ClaimsController < CaseWorkers::ApplicationController before_action :filter_archived_claims, only: [:archived] before_action :sort_claims, only: %i[index archived] before_action :set_claim, only: %i[show messages download_zip] + before_action :set_show_maat_details include ReadMessages include MessageControlsDisplay @@ -131,5 +132,14 @@ def sort_claims def criteria_params { sorting: sort_column, direction: sort_direction, page: current_page, limit: page_size, search: search_terms } end + + def set_show_maat_details + if params[:maat_details].present? + @show_maat_details = params[:maat_details] == 'on' ? true : false + current_user.save_setting!(maat_details: @show_maat_details) + else + @show_maat_details = current_user.setting?(:maat_details) || false + end + end end end diff --git a/app/views/shared/_claim.html.haml b/app/views/shared/_claim.html.haml index bbca000b72..d07e073df9 100644 --- a/app/views/shared/_claim.html.haml +++ b/app/views/shared/_claim.html.haml @@ -84,7 +84,12 @@ %h3.govuk-heading-m = t('.defendants') - = render partial: 'shared/claim_defendants', locals: {defendants: claim.defendants } + - if @show_maat_details + = govuk_link_to t('.disable_maat_details'), '?maat_details=off' + = render partial: 'shared/claim_defendants_with_maat', locals: {defendants: claim.defendants } + - else + = govuk_link_to t('.enable_maat_details'), '?maat_details=on' + = render partial: 'shared/claim_defendants', locals: {defendants: claim.defendants } - else .govuk-grid-row diff --git a/app/views/shared/_claim_defendant_details_with_maat.html.haml b/app/views/shared/_claim_defendant_details_with_maat.html.haml new file mode 100644 index 0000000000..04e16950b5 --- /dev/null +++ b/app/views/shared/_claim_defendant_details_with_maat.html.haml @@ -0,0 +1,37 @@ +.app-card--defendant + %h4.govuk-heading-s + = t('.defendant', context: index) + + = govuk_summary_list do + = govuk_summary_list_row_collection( t('external_users.claims.defendants.defendant_fields.full_name') ) { defendant.name } + + - if defendant.date_of_birth.present? + = govuk_summary_list_row_collection( t('external_users.claims.defendants.defendant_fields.date_of_birth') ) { defendant.date_of_birth.strftime(Settings.date_format) rescue '' } + + - unless @claim.lgfs? && @claim.interim? + = govuk_summary_list_row_collection( t('external_users.claims.defendants.defendant_fields.judical_apportionment') ) { defendant.order_for_judicial_apportionment == true ? t('global_yes') : t('global_no') } + + + - if defendant.representation_orders.any? + = govuk_table do + = govuk_table_caption do + = t('shared.claim.reporders') + + = govuk_table_thead_collection [t('.date'), + t('external_users.claims.defendants.representation_order_fields.maat_reference_number'), + t('.case_number_from_maat')] + + = govuk_table_tbody do + - defendant.representation_orders.each do | representation_order | + = govuk_table_row do + = govuk_table_td('data-label': t('.date')) do + = representation_order.representation_order_date.strftime(Settings.date_format) rescue '' + + = govuk_table_td('data-label': t('external_users.claims.defendants.representation_order_fields.maat_reference_number')) do + = representation_order.maat_reference + + = govuk_table_td('data-label': t('.case_number_from_maat')) do + = representation_order.maat_details[:case_number] + + - else + = govuk_inset_text(t('.no_reporder')) diff --git a/app/views/shared/_claim_defendants.html.haml b/app/views/shared/_claim_defendants.html.haml index 7d89a46759..699acc6d4d 100644 --- a/app/views/shared/_claim_defendants.html.haml +++ b/app/views/shared/_claim_defendants.html.haml @@ -1,3 +1,3 @@ - defendants.each_with_index do | defendant, index | .govuk-grid-column-one-half - = render partial: 'shared/claim_defendant_details', locals: { defendant: present(defendant, CaseWorkers::DefendantPresenter), index: index += 1 } + = render partial: 'shared/claim_defendant_details', locals: { defendant:, index: index += 1 } diff --git a/app/views/shared/_claim_defendants_with_maat.html.haml b/app/views/shared/_claim_defendants_with_maat.html.haml new file mode 100644 index 0000000000..836880bfb4 --- /dev/null +++ b/app/views/shared/_claim_defendants_with_maat.html.haml @@ -0,0 +1,3 @@ +- defendants.each_with_index do | defendant, index | + .govuk-grid-column-one-half + = render partial: 'shared/claim_defendant_details_with_maat', locals: { defendant: present(defendant, CaseWorkers::DefendantPresenter), index: index += 1 } diff --git a/config/locales/en.yml b/config/locales/en.yml index 2beef7ca46..0b9281f879 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2024,11 +2024,19 @@ en: banner_paragraph: This is to enable routine maintenance work to be carried out. Please save and close any work before this time. claim_defendants: defendants: Defendants + enable_maat_details: Enable MAAT details (experimental) + disable_maat_details: Disable MAAT details (experimental) claim_defendant_details: caption: 'Defendant: Additional information' date: Order date defendant: Defendant %{context} no_reporder: No representation orders have been supplied for this defendant. + claim_defendant_details_with_maat: + caption: 'Defendant: Additional information' + date: Order date + defendant: Defendant %{context} + no_reporder: No representation orders have been supplied for this defendant. + case_number_from_maat: Case number from MAAT (experimental) evidence_checklist: caption: 'Supporting evidence checklist' summary: 'Note: To best navigate this table, step down the second column' @@ -2098,6 +2106,8 @@ en: submit_date: Claim submitted trial_concluded: Trial concluded prosecution_evidence: Prosecution evidence + enable_maat_details: Enable MAAT details (experimental) + disable_maat_details: Disable MAAT details (experimental) claims: interim_claim_info: fields: *interim_claim_info_fields