-
Notifications
You must be signed in to change notification settings - Fork 2
HDPI-5493 - Create Document Type list dynamically for England and Wales specific #1850
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
base: master
Are you sure you want to change the base?
Changes from all commits
5aa8850
4eca8cd
276026d
f5226ec
9049f37
7c597f4
ad44ece
65344b4
411c391
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.domain; | ||
|
|
||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
| import uk.gov.hmcts.ccd.sdk.api.CCD; | ||
| import uk.gov.hmcts.ccd.sdk.type.Document; | ||
| import uk.gov.hmcts.ccd.sdk.type.DynamicList; | ||
| import uk.gov.hmcts.ccd.sdk.type.FieldType; | ||
| import uk.gov.hmcts.reform.pcs.ccd.accesscontrol.CitizenAccess; | ||
|
|
||
| @Data | ||
| @Builder | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public class AdditionalDocuments { | ||
|
|
||
| @CCD( | ||
| label = "Type of document", | ||
| access = {CitizenAccess.class} | ||
| ) | ||
| private DynamicList documentTypeList; | ||
|
|
||
| @CCD(label = "Document", access = {CitizenAccess.class}) | ||
| private Document document; | ||
|
|
||
| @CCD(label = "Short description", | ||
| typeOverride = FieldType.TextArea, | ||
| access = {CitizenAccess.class} | ||
| ) | ||
| private String description; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -427,12 +427,19 @@ public class PCSCase { | |
| ) | ||
| private VerticalYesNo wantToUploadDocuments; | ||
|
|
||
| @Deprecated(since = "05-19-2026", forRemoval = true) | ||
| @CCD( | ||
| label = "Add document", | ||
| hint = "Upload a document to the system" | ||
| ) | ||
| private List<ListValue<AdditionalDocument>> additionalDocuments; | ||
|
|
||
| @CCD( | ||
| label = "Add document", | ||
| hint = "Upload a document to the system" | ||
| ) | ||
| private List<ListValue<AdditionalDocuments>> additionalDocs; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't feel very clean to have another field which has a similar name to the one above. I presume you're only doing it to prevent an issue with the ES index but I think at this stage it would be better to make the change properly and be ready to drop the ES index since we're not in Prod yet. Also it would be better to re-use the existing |
||
|
|
||
| @CCD( | ||
| label = "Are you planning to make an application at the same time as your claim?", | ||
| hint = "After you’ve submitted your claim, there will be instructions on how to make an application" | ||
|
|
@@ -547,6 +554,7 @@ public class PCSCase { | |
| private ComponentLauncher caseFileView; | ||
|
|
||
| @CCD(searchable = false) | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor vertical spacing? |
||
| private String formattedDefendantNames; | ||
| private String formattedPropertyAddress; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,76 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.page.resumepossessionclaim; | ||
|
|
||
| import org.springframework.stereotype.Component; | ||
| import uk.gov.hmcts.ccd.sdk.api.CaseDetails; | ||
| import uk.gov.hmcts.ccd.sdk.api.callback.AboutToStartOrSubmitResponse; | ||
| import uk.gov.hmcts.ccd.sdk.type.DynamicList; | ||
| import uk.gov.hmcts.ccd.sdk.type.DynamicListElement; | ||
| import uk.gov.hmcts.ccd.sdk.type.ListValue; | ||
| import uk.gov.hmcts.reform.pcs.ccd.common.CcdPageConfiguration; | ||
| import uk.gov.hmcts.reform.pcs.ccd.common.PageBuilder; | ||
| import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalDocumentType; | ||
| import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalDocuments; | ||
| import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; | ||
| import uk.gov.hmcts.reform.pcs.ccd.domain.State; | ||
| import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; | ||
| import uk.gov.hmcts.reform.pcs.ccd.page.CommonPageContent; | ||
| import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.UUID; | ||
|
|
||
| @Component | ||
| public class WantToUploadDocuments implements CcdPageConfiguration { | ||
|
|
||
| @Override | ||
| public void addTo(PageBuilder pageBuilder) { | ||
| pageBuilder | ||
| .page("wantToUploadDocuments") | ||
| .page("wantToUploadDocuments", this::midEvent) | ||
| .pageLabel("Upload additional documents") | ||
| .label("wantToUploadDocuments-separator", "---") | ||
| .mandatory(PCSCase::getWantToUploadDocuments) | ||
| .label("wantToUploadDocuments-saveAndReturn", CommonPageContent.SAVE_AND_RETURN); | ||
| } | ||
|
|
||
| private AboutToStartOrSubmitResponse<PCSCase, State> midEvent(CaseDetails<PCSCase, State> details, | ||
| CaseDetails<PCSCase, State> detailsBefore) { | ||
| PCSCase caseData = details.getData(); | ||
|
|
||
| if (caseData.getWantToUploadDocuments().equals(VerticalYesNo.YES)) { | ||
| AdditionalDocuments additionalDocuments = new AdditionalDocuments(); | ||
| LegislativeCountry legislativeCountry = caseData.getLegislativeCountry(); | ||
|
|
||
| additionalDocuments.setDocumentTypeList(createAdditionalDocumentList(legislativeCountry)); | ||
| caseData.setAdditionalDocs(new ArrayList<>()); | ||
| caseData.getAdditionalDocs().add(ListValue.<AdditionalDocuments>builder() | ||
| .value(additionalDocuments) | ||
| .build()); | ||
| } | ||
|
|
||
| return AboutToStartOrSubmitResponse.<PCSCase, State>builder() | ||
| .data(caseData) | ||
| .build(); | ||
| } | ||
|
|
||
| private DynamicList createAdditionalDocumentList(LegislativeCountry legislativeCountry) { | ||
|
|
||
| DynamicList documentTypeList = new DynamicList(null, new ArrayList<>()); | ||
|
|
||
| for (AdditionalDocumentType dt : AdditionalDocumentType.values()) { | ||
| if (canAddDocumentType(dt, legislativeCountry)) { | ||
| DynamicListElement element = new DynamicListElement(UUID.randomUUID(), dt.getLabel()); | ||
| documentTypeList.getListItems().add(element); | ||
| } | ||
| } | ||
|
|
||
| return documentTypeList; | ||
| } | ||
|
|
||
| private boolean canAddDocumentType(AdditionalDocumentType dt, LegislativeCountry country) { | ||
| if (country.equals(LegislativeCountry.ENGLAND)) { | ||
| return AdditionalDocumentType.isEnglandSpecific(dt) || !AdditionalDocumentType.isWalesSpecific(dt); | ||
| } else { | ||
| return AdditionalDocumentType.isWalesSpecific(dt) || !AdditionalDocumentType.isEnglandSpecific(dt); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a more elegant way to achieve this is for the enum constructor to take a Set of the legislative countries for which it applies. See
ClaimantTypefor an example.It also makes it easier to build up the dynamic list to show based on the legislative country.