-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CCAP-470] create providerresponse registration service languages scr…
…een (#1006)
- Loading branch information
Showing
10 changed files
with
400 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/main/java/org/ilgcc/app/pdf/ProviderLanguagesPreparer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package org.ilgcc.app.pdf; | ||
|
||
import formflow.library.data.Submission; | ||
import formflow.library.pdf.PdfMap; | ||
import formflow.library.pdf.SingleField; | ||
import formflow.library.pdf.SubmissionField; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import org.ilgcc.app.utils.enums.ProviderLanguagesOffered; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class ProviderLanguagesPreparer extends ProviderSubmissionFieldPreparer { | ||
|
||
@Override | ||
public Map<String, SubmissionField> prepareSubmissionFields(Submission familySubmission, PdfMap pdfMap) { | ||
var results = new HashMap<String, SubmissionField>(); | ||
Optional<Submission> providerSubmission = getProviderSubmission(familySubmission); | ||
if (providerSubmission.isEmpty()) { | ||
return results; | ||
} | ||
|
||
var providerInputData = providerSubmission.get().getInputData(); | ||
List<String> otherLanguages = new ArrayList<>(); | ||
if (providerInputData.containsKey("providerLanguagesOffered[]")) { | ||
List<String> providerLanguagesOffered = (List<String>) providerInputData.get("providerLanguagesOffered[]"); | ||
if (providerLanguagesOffered.isEmpty() || providerLanguagesOffered.contains("NONE")) { | ||
return results; | ||
} | ||
|
||
for (ProviderLanguagesOffered provider : ProviderLanguagesOffered.values()) { | ||
if (providerLanguagesOffered.contains(provider.getValue())) { | ||
if (!provider.getProviderLanguagePdfFieldValue().equalsIgnoreCase("Other")) { | ||
String pdfMapInputName = String.format("providerLanguage%s", provider.getValue()); | ||
results.put(pdfMapInputName, new SingleField(pdfMapInputName, "true", null)); | ||
} else { | ||
results.put("providerLanguageOther", new SingleField("providerLanguageOther", "true", null)); | ||
otherLanguages.add(provider.getProviderLanguageOtherDetailPdfFieldValue()); | ||
} | ||
} | ||
} | ||
|
||
if (providerLanguagesOffered.contains("other")) { | ||
if (otherLanguages.isEmpty()) { | ||
results.put("providerLanguageOther", new SingleField("providerLanguageOther", "true", null)); | ||
} | ||
} | ||
|
||
if (!otherLanguages.isEmpty()) { | ||
String otherLanguagesList = String.join(", ", otherLanguages); | ||
results.put("providerLanguageOtherDetail", new SingleField("providerLanguageOtherDetail", otherLanguagesList, null)); | ||
} | ||
return results; | ||
} | ||
return results; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/org/ilgcc/app/utils/enums/ProviderLanguagesOffered.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.ilgcc.app.utils.enums; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
|
||
public enum ProviderLanguagesOffered { | ||
ENGLISH("registration-service-languages.provider-languages.english", "English", "ENGLISH", ""), | ||
SPANISH("registration-service-languages.provider-languages.spanish" ,"Spanish", "SPANISH", ""), | ||
POLISH("registration-service-languages.provider-languages.polish","Polish", "POLISH", ""), | ||
CHINESE("registration-service-languages.provider-languages.chinese" ,"Chinese", "CHINESE", ""), | ||
TAGALOG("registration-service-languages.provider-languages.tagalog", "Tagalog","OTHER", | ||
"Tagalog (including Filipino)"), | ||
HINDI("registration-service-languages.provider-languages.hindi", "Hindi","OTHER", "Hindi"), | ||
ARABIC("registration-service-languages.provider-languages.arabic", "Arabic","OTHER", "Arabic"); | ||
private final String label; | ||
private final String value; | ||
private final String providerLanguagePdfFieldValue; | ||
private final String providerLanguageOtherDetailPdfFieldValue; | ||
|
||
ProviderLanguagesOffered(String label, String value ,String providerLanguagePdfFieldValue, String providerLanguageOtherDetailPdfFieldValue) { | ||
this.label = label; | ||
this.value = value; | ||
this.providerLanguagePdfFieldValue = providerLanguagePdfFieldValue; | ||
this.providerLanguageOtherDetailPdfFieldValue = providerLanguageOtherDetailPdfFieldValue; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
68 changes: 40 additions & 28 deletions
68
src/main/resources/templates/providerresponse/registration-service-languages.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,40 @@ | ||
<!DOCTYPE html> | ||
<html th:lang="${#locale.language}" xmlns:th="http://www.thymeleaf.org"> | ||
<head th:replace="~{fragments/head :: head(title='TEMPLATE')}"></head> | ||
<body> | ||
<div class="page-wrapper"> | ||
<div th:replace="~{fragments/toolbar :: toolbar}"></div> | ||
<section class="slab"> | ||
<div class="grid"> | ||
<div th:replace="~{fragments/goBack :: goBackLink}"></div> | ||
<main id="content" role="main" class="form-card spacing-above-35"> | ||
<th:block th:replace="~{fragments/cardHeader :: cardHeader(header='#{placeholder}', subtext='#{placeholder}')}"/> | ||
<th:block th:replace="~{fragments/form :: form(action=${formAction}, content=~{::formContent})}"> | ||
<th:block th:ref="formContent"> | ||
<div class="form-card__content"> | ||
|
||
</div> | ||
<div class="form-card__footer"> | ||
<th:block th:replace="~{fragments/inputs/submitButton :: submitButton(text=#{general.inputs.continue})}"/> | ||
</div> | ||
</th:block> | ||
</th:block> | ||
</main> | ||
</div> | ||
</section> | ||
</div> | ||
<th:block th:replace="~{fragments/footer :: footer}"/> | ||
</body> | ||
</html> | ||
<th:block | ||
th:replace="~{fragments/screens/screenWithOneInput :: | ||
screenWithOneInput( | ||
title=#{registration-service-languages.title}, | ||
header=#{registration-service-languages.header}, | ||
iconFragment=~{fragments/gcc-icons :: language-preference}, | ||
required='true', | ||
buttonLabel=#{general.inputs.continue}, | ||
formAction=${formAction}, | ||
inputContent=~{::inputContent})}"> | ||
<th:block th:ref="inputContent"> | ||
<th:block th:replace="~{fragments/inputs/checkboxFieldset :: | ||
checkboxFieldset(inputName='providerLanguagesOffered', | ||
noneOfTheAboveLabel=#{general.inputs.prefer-not-to-answer}, | ||
ariaLabel='header', | ||
content=~{::providerLanguagesContent})}"> | ||
<th:block th:ref="providerLanguagesContent"> | ||
<th:block th:each="option : ${T(org.ilgcc.app.utils.enums.ProviderLanguagesOffered).values()}"> | ||
<th:block th:replace="~{fragments/inputs/checkboxInSet :: | ||
checkboxInSet(inputName=${inputName}, | ||
value=${option.getValue()}, | ||
label=${#strings.isEmpty(option.getLabel()) ? null : #messages.msg(option.getLabel())})}"/> | ||
</th:block> | ||
<div class="question-with-follow-up spacing-below-15"> | ||
<div class="question-with-follow-up__question"> | ||
<th:block | ||
th:replace="~{fragments/inputs/checkboxInSet :: checkboxInSet(inputName=${inputName},value='other', label=#{registration-service-languages.provider-languages.other}, followUpId='#provider-languages-other-followUp')}"/> | ||
</div> | ||
<div class="question-with-follow-up__follow-up" id="provider-languages-other-followUp"> | ||
<th:block th:replace="~{fragments/inputs/text :: | ||
text(inputName='providerLanguagesOffered_other', | ||
label=#{registration-service-languages.provider-languages.other-follow-up})}"/> | ||
</div> | ||
</div> | ||
<th:block th:replace="~{fragments/inputs/checkboxInSet :: | ||
checkboxInSet(inputName=${inputName}, value='NONE', label=${noneOfTheAboveLabel}, noneOfTheAbove=true)}"/> | ||
</th:block> | ||
</th:block> | ||
</th:block> | ||
</th:block> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.