generated from codeforamerica/form-flow-starter-app
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement household sensitive questions flow (#348)
* basic implementation of screens * before save action cleans up data * tests :) * just cleaned up code a bit and made names more intuitive --------- Co-authored-by: Ana Medrano Fernandez <amedrano@codeforamerica.org@Anas-MacBook-Pro-2.local>
- Loading branch information
Showing
13 changed files
with
257 additions
and
94 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
61 changes: 61 additions & 0 deletions
61
...main/java/org/ladocuploader/app/submission/actions/ReformatPersonalSituationUserData.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,61 @@ | ||
package org.ladocuploader.app.submission.actions; | ||
|
||
import formflow.library.config.submission.Action; | ||
import formflow.library.data.Submission; | ||
import java.util.ArrayList; | ||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* | ||
*/ | ||
@Component | ||
@Slf4j | ||
public class ReformatPersonalSituationUserData implements Action { | ||
|
||
@Override | ||
public void run(Submission submission) { | ||
Map<String, Object> inputData = submission.getInputData(); | ||
|
||
submission.getInputData().put("affectedByPersonalSituations[]", reformatPersonalSituations(inputData)); | ||
} | ||
|
||
private ArrayList<LinkedHashMap> reformatPersonalSituations(Map<String, Object> inputData) { | ||
ArrayList<LinkedHashMap> householdMembers = (ArrayList) inputData.get("household"); | ||
ArrayList<String> hasPersonalSituations = (ArrayList) inputData.get("personalSituationsHouseholdUUID[]"); | ||
ArrayList<LinkedHashMap> personalSituationsObject = new ArrayList<>(); | ||
|
||
hasPersonalSituations.forEach((String id) -> { | ||
LinkedHashMap user = new LinkedHashMap(); | ||
if (id.equals("you")) { | ||
user.put("uuid", id); | ||
user.put("firstName", inputData.get("firstName") + " (you)"); | ||
user.put("lastName", inputData.get("lastName")); | ||
personalSituationsObject.add(user); | ||
} else { | ||
personalSituationsObject.add(householdData(householdMembers, id)); | ||
} | ||
} | ||
); | ||
|
||
return personalSituationsObject; | ||
|
||
} | ||
|
||
private LinkedHashMap householdData(ArrayList<LinkedHashMap> household, String uuid) { | ||
LinkedHashMap user = new LinkedHashMap(); | ||
for (LinkedHashMap hhmember : household) { | ||
if (hhmember.get("uuid").equals(uuid)) { | ||
user.put("uuid", uuid); | ||
user.put("firstName", hhmember.get("householdMemberFirstName")); | ||
user.put("lastName", hhmember.get("householdMemberLastName")); | ||
continue; | ||
} | ||
} | ||
|
||
return user; | ||
}; | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
...main/java/org/ladocuploader/app/submission/conditions/HouseholdHasPersonalSituations.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,17 @@ | ||
package org.ladocuploader.app.submission.conditions; | ||
|
||
import formflow.library.config.submission.Condition; | ||
import formflow.library.data.Submission; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class HouseholdHasPersonalSituations implements Condition { | ||
@Override | ||
public Boolean run(Submission submission) { | ||
var inputData = submission.getInputData(); | ||
if (inputData.containsKey("householdHasPersonalSituations")) { | ||
return submission.getInputData().get("householdHasPersonalSituations").equals("true"); | ||
} | ||
return false; | ||
} | ||
} |
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
21 changes: 14 additions & 7 deletions
21
src/main/resources/templates/laDigitalAssister/householdCriminalJusticeSituations.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
29 changes: 0 additions & 29 deletions
29
src/main/resources/templates/laDigitalAssister/householdMoreInfoPersonalSituations.html
This file was deleted.
Oops, something went wrong.
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
17 changes: 10 additions & 7 deletions
17
src/main/resources/templates/laDigitalAssister/householdPersonalSituationsWho.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
19 changes: 6 additions & 13 deletions
19
...ain/resources/templates/laDigitalAssister/householdSensitiveQuestionsCriminalJustice.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
Oops, something went wrong.