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

Updating FFL fragments #72

Merged
merged 6 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
29 changes: 29 additions & 0 deletions src/main/java/org/ilgcc/app/utils/GenderOption.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.ilgcc.app.utils;

import lombok.Getter;

@Getter
public enum GenderOption implements InputOption {

MALE("general.inputs.male"),
FEMALE("general.inputs.female"),
NONBINARY("general.inputs.non-binary"),
TRANSGENDER("general.inputs.transgender"),
NO_ANSWER("general.inputs.prefer-not-to-answer");

private final String label;

GenderOption(String label) {
this.label = label;
}

@Override
public String getValue() {
return this.name();
}

@Override
public String getHelpText() {
return null;
}
}
11 changes: 11 additions & 0 deletions src/main/java/org/ilgcc/app/utils/InputOption.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.ilgcc.app.utils;


public interface InputOption {

String getLabel();

String getValue();

String getHelpText();
}
33 changes: 33 additions & 0 deletions src/main/java/org/ilgcc/app/utils/RaceEthnicityOption.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.ilgcc.app.utils;

import lombok.Getter;

@Getter
public enum RaceEthnicityOption implements InputOption {

ASIAN("general.inputs.race-ethnicity.asian"),
BLACK("general.inputs.race-ethnicity.black-or-african-american"),
HISPANIC("general.inputs.race-ethnicity.hispanic-latino-or-spanish"),
MIDDLE_EASTERN("general.inputs.race-ethnicity.middle-eastern-or-north-african"),
NATIVE_AMERICAN("general.inputs.race-ethnicity.native-american-or-alaska-native"),
NATIVE_HAWAIIAN("general.inputs.race-ethnicity.native-hawaiian-or-pacific-islander"),
WHITE("general.inputs.race-ethnicity.white"),
OTHER("general.inputs.race-ethnicity.other");

private final String label;

RaceEthnicityOption(String label) {
this.label = label;
}

@Override
public String getValue() {
return this.name();
}

@Override
public String getHelpText() {
return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<th:block
th:fragment="checkboxFieldset"
th:with="
hasHelpText=${!#strings.isEmpty(fieldsetHelpText)},
hasLabel=${!#strings.isEmpty(label)},
hasAriaLabel=${!#strings.isEmpty(ariaLabel)},
hasOptions=${options != null},
hasContent=${!hasOptions},
hasError=${
errorMessages != null &&
errorMessages.get(inputName) != null &&
(#arrays.length(errorMessages.get(inputName)) > 0) }"
th:assert="
${!#strings.isEmpty(inputName)},
${hasLabel || hasAriaLabel},
${hasContent || hasOptions}">
<div th:class="'form-group' + ${(hasError ? ' form-group--error' : '')}">
<fieldset th:attr="
aria-describedby=${hasHelpText ? inputName + '-help-text' : ''},
aria-labelledby=${hasAriaLabel ? ariaLabel : ''}">
<legend class="form-question"
th:if="${hasLabel}"
th:id="${inputName + '-legend'}"
th:inline="text">
[[${label}]]
<p class="text--help spacing-below-0 text--normal"
th:if="${hasHelpText}"
th:id="${inputName + '-help-text'}"
th:text="${fieldsetHelpText}"></p>
</legend>
<input type="hidden" th:id="${inputName} + 'Hidden'" th:name="${inputName} + '[]'" value="">
<th:block th:if="${hasContent}">
<th:block th:replace="${content}"/>
</th:block>
<th:block th:if="${hasOptions}">
<th:block th:each="option : ${options}">
<th:block th:replace="~{fragments/inputs/checkboxInSet ::
checkboxInSet(inputName=${inputName},
value=${option.getValue()},
label=${#strings.isEmpty(option.getLabel()) ? null : #messages.msg(option.getLabel())},
checkboxHelpText=${#strings.isEmpty(option.getHelpText()) ? null : #messages.msg(option.getHelpText())})}"/>
</th:block>
</th:block>
<th:block
th:replace="~{fragments/inputError :: validationError(inputName=${inputName})}"></th:block>
</fieldset>
</div>
</th:block>
47 changes: 47 additions & 0 deletions src/main/resources/templates/fragments/inputs/radioFieldset.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<th:block
th:fragment="radioFieldset"
th:with="
hasHelpText=${!#strings.isEmpty(fieldsetHelpText)},
hasLabel=${!#strings.isEmpty(label)},
hasAriaLabel=${!#strings.isEmpty(ariaLabel)},
hasOptions=${options != null},
hasContent=${!hasOptions},
hasError=${
errorMessages != null &&
errorMessages.get(inputName) != null &&
(#arrays.length(errorMessages.get(inputName)) > 0) }"
th:assert="
${!#strings.isEmpty(inputName)},
${hasLabel || hasAriaLabel},
${hasContent || hasOptions}">
<div th:class="'form-group' + ${(hasError ? ' form-group--error' : '')}">
<fieldset th:attr="
aria-describedby=${hasHelpText ? inputName + '-help-text' : ''},
aria-labelledby=${hasAriaLabel ? ariaLabel : ''}">
<legend class="form-question"
th:id="${inputName + '-legend'}"
th:inline="text">
[[${label}]]
<p class="text--help spacing-below-0 text--normal"
th:if="${hasHelpText}"
th:id="${inputName + '-help-text'}"
th:text="${fieldsetHelpText}"></p>
</legend>
<input type="hidden" th:id="${inputName} + 'Hidden'" th:name="${inputName}" value="">
<th:block th:if="${hasContent}">
<th:block th:replace="${content}"/>
</th:block>
<th:block th:if="${hasOptions}">
<th:block th:each="option : ${options}">
<th:block th:replace="~{fragments/inputs/radio ::
radio(inputName=${inputName},
value=${option.getValue()},
label=#{${option.getLabel()}},
radioHelpText=#{${option.getHelpText()}})}"/>
</th:block>
</th:block>
</fieldset>
<th:block
th:replace="~{fragments/inputError :: validationError(inputName=${inputName})}"></th:block>
</div>
</th:block>
37 changes: 10 additions & 27 deletions src/main/resources/templates/gcc/children-ccap-info.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,15 @@
<th:block
th:replace="~{fragments/cardHeader :: cardHeader(header=#{children-ccap-info.header(${fieldData.get('childFirstName')})}, subtext=#{children-ccap-info.subheader})}"/>
<th:block th:replace="~{fragments/form :: form(action=${formAction}, content=~{::formContent})}">
<th:block th:ref="formContent">
<th:block th:ref="formContent"
th:with="
genderOptions=${T(org.ilgcc.app.utils.GenderOption).values()},
raceEthnicityOptions=${T(org.ilgcc.app.utils.RaceEthnicityOption).values()}">
<div class="form-card__content">
<th:block th:replace="~{'fragments/inputs/checkboxFieldset' ::
<th:block th:replace="~{fragments/inputs/checkboxFieldset ::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sree-cfa, how many options can the user check on this screen? If only one is possible, it should be Radio.

checkboxFieldset(inputName='childGender',
label=#{children-ccap-info.gender-question},
content=~{::genderContent})}">
<th:block th:ref="genderContent">
<th:block th:replace="~{fragments/inputs/checkboxInSet :: checkboxInSet(inputName='childGender', value='MALE', label=#{general.inputs.male})}"/>
<th:block th:replace="~{fragments/inputs/checkboxInSet :: checkboxInSet(inputName='childGender', value='FEMALE', label=#{general.inputs.female})}"/>
<th:block th:replace="~{fragments/inputs/checkboxInSet :: checkboxInSet(inputName='childGender', value='NONBINARY', label=#{general.inputs.non-binary})}"/>
<th:block th:replace="~{fragments/inputs/checkboxInSet :: checkboxInSet(inputName='childGender', value='TRANSGENDER', label=#{general.inputs.transgender})}"/>
<th:block th:replace="~{fragments/inputs/checkboxInSet :: checkboxInSet(inputName='childGender', value='NO_ANSWER', label=#{general.inputs.prefer-not-to-answer})}"/>
</th:block>
</th:block>
label=#{children-ccap-info.gender-question},
options=${genderOptions})}"/>

<th:block th:replace="~{fragments/inputs/radioFieldset ::
radioFieldset(inputName='childHasDisability',
Expand Down Expand Up @@ -59,22 +54,10 @@
</th:block>
</th:block>

<th:block th:replace="~{'fragments/inputs/checkboxFieldset' ::
<th:block th:replace="~{fragments/inputs/checkboxFieldset ::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gender and race should be checked as only one option, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question - I'll double check with Carlie. The design shows checkboxes implying it can have multiple answers so I'll leave it like that for now

checkboxFieldset(inputName='childRaceEthnicity',
label=#{children-ccap-info.race-ethnicity-question},
fieldsetHelpText=#{children-ccap-info.race-ethnicity-help-text},
content=~{::raceEthnicityContent})}">
<th:block th:ref="raceEthnicityContent">
<th:block th:replace="~{fragments/inputs/checkboxInSet :: checkboxInSet(inputName='childRaceEthnicity', value='ASIAN', label=#{general.inputs.race-ethnicity.asian})}"/>
<th:block th:replace="~{fragments/inputs/checkboxInSet :: checkboxInSet(inputName='childRaceEthnicity', value='BLACK', label=#{general.inputs.race-ethnicity.black-or-african-american})}"/>
<th:block th:replace="~{fragments/inputs/checkboxInSet :: checkboxInSet(inputName='childRaceEthnicity', value='HISPANIC', label=#{general.inputs.race-ethnicity.hispanic-latino-or-spanish})}"/>
<th:block th:replace="~{fragments/inputs/checkboxInSet :: checkboxInSet(inputName='childRaceEthnicity', value='MIDDLE_EASTERN', label=#{general.inputs.race-ethnicity.middle-eastern-or-north-african})}"/>
<th:block th:replace="~{fragments/inputs/checkboxInSet :: checkboxInSet(inputName='childRaceEthnicity', value='NATIVE_AMERICAN', label=#{general.inputs.race-ethnicity.native-american-or-alaska-native})}"/>
<th:block th:replace="~{fragments/inputs/checkboxInSet :: checkboxInSet(inputName='childRaceEthnicity', value='NATIVE_HAWAIIAN', label=#{general.inputs.race-ethnicity.native-hawaiian-or-pacific-islander})}"/>
<th:block th:replace="~{fragments/inputs/checkboxInSet :: checkboxInSet(inputName='childRaceEthnicity', value='WHITE', label=#{general.inputs.race-ethnicity.white})}"/>
<th:block th:replace="~{fragments/inputs/checkboxInSet :: checkboxInSet(inputName='childRaceEthnicity', value='other', label=#{general.inputs.race-ethnicity.other})}"/>
</th:block>
</th:block>
label=#{children-ccap-info.race-ethnicity-question},
options=${raceEthnicityOptions})}"/>
</div>
<div class="form-card__footer">
<th:block th:replace="~{fragments/inputs/submitButton :: submitButton(text=#{general.inputs.continue})}"/>
Expand Down
Loading