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

Adding children-ccap-other-ed screen #68

Merged
merged 2 commits into from
Feb 26, 2024
Merged
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
2 changes: 2 additions & 0 deletions src/main/java/org/ilgcc/app/inputs/Gcc.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ public class Gcc extends FlowInputs {
private String ccapStartDate;

private List<String> childcareWeeklySchedule;

private String childAttendsOtherEd;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.ilgcc.app.submission.conditions;

import formflow.library.config.submission.Condition;
import formflow.library.data.Submission;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

import static java.util.Collections.emptyList;
import static org.ilgcc.app.utils.SubmissionUtilities.MM_DD_YYYY;

@Component
public class IsFiveOrOlder implements Condition {
private static final LocalDate FIVE_YEARS_AGO = LocalDate.now().minusYears(5);

@Override
public Boolean run(Submission submission, String uuid) {
var children = (List<Map<String, Object>>) submission.getInputData().getOrDefault("children", emptyList());
for (var child : children) {
if (child.get("uuid").equals(uuid)) {
var bday = getChildBirthday(child);
return bday.isBefore(FIVE_YEARS_AGO);
}
}

return false;
}

private LocalDate getChildBirthday(Map<String, Object> child) {
var bdayString = String.format("%s/%s/%s",
child.get("childDateOfBirthMonth"),
child.get("childDateOfBirthDay"),
child.get("childDateOfBirthYear"));
return LocalDate.parse(bdayString, MM_DD_YYYY);
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/ilgcc/app/utils/SubmissionUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import static java.util.Collections.emptyList;

public class SubmissionUtilities {

public static final DateTimeFormatter MM_DD_YYYY = DateTimeFormatter.ofPattern("M/d/uuuu");
public static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MMMM dd, yyy");
public static final String PROGRAM_SCHEDULE = "programSchedule";

Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/flows-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ flow:
subflow: children
nextScreens:
# - name: children-childcare-hourly-schedule
- name: children-add # skipping WIP screens
- name: children-ccap-child-other-ed # Skip WIP screens
condition: IsFiveOrOlder
- name: children-add
children-childcare-hourly-schedule:
subflow: children
nextScreens:
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ children-childcare-weekly-schedule.header=What days is {0} in child care?

#children-childcare-hourly-schedule
#children-ccap-child-other-ed
children-ccap-child-other-ed.title=CCAP Child Other
children-ccap-child-other-ed.header=Does {0} attend any other school or education program during the day?
#
#activities-parent-intro
#activities-parent-type
Expand Down
38 changes: 10 additions & 28 deletions src/main/resources/templates/gcc/children-ccap-child-other-ed.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,10 @@
<!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">
<!-- Put inputs here -->
</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/screenWithYesAndNoButtons ::
screenWithYesAndNoButtons(
title=#{children-ccap-child-other-ed.title},
header=#{children-ccap-child-other-ed.header(${fieldData.get('childFirstName')})},
inputName='childAttendsOtherEd',
inputContent=~{::inputContent})}">
<th:block th:ref="inputContent">
</th:block>
</th:block>
5 changes: 4 additions & 1 deletion src/test/java/org/ilgcc/app/journeys/GccFlowJourneyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void fullGccFlow() {
testPage.enter("childLastName", "mcchild");
testPage.enter("childDateOfBirthMonth", "12");
testPage.enter("childDateOfBirthDay", "25");
testPage.enter("childDateOfBirthYear", "2020");
testPage.enter("childDateOfBirthYear", "2018");
testPage.selectRadio("needFinancialAssistanceForChild", "Yes");
testPage.clickButton("Continue");
//children-ccap-info
Expand Down Expand Up @@ -69,6 +69,9 @@ void fullGccFlow() {
//children-ccap-weekly-schedule
assertThat(testPage.getTitle()).isEqualTo("CCAP Childcare Weekly Schedule");
testPage.clickContinue();
//children-ccap-child-other-ed
assertThat(testPage.getTitle()).isEqualTo("CCAP Child Other");
testPage.clickButton("Yes");
// children-add (with children listed)
assertThat(testPage.getTitle()).isEqualTo("Children add");
List<String> li = testPage.getTextBySelector(".child-name");
Expand Down
Loading