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

Enable field 2 in Basic State Information #139460

Merged
merged 15 commits into from
Sep 25, 2023
Merged
1 change: 0 additions & 1 deletion services/app-api/handlers/formTemplates/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export const post = handler(async (event, _context) => {
stateStatuses.push({
stateId: state.code,
year: yearNumber,
programType: state.programType,
gmrabian marked this conversation as resolved.
Show resolved Hide resolved
status: "not_started",
lastChanged: creationTime,
});
Expand Down
1 change: 0 additions & 1 deletion services/database/data/seed/seed-section-base-2023.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"value": "separate_chip"
}
],
"readonly": true,
"prepopulated": true
}
},
Expand Down
7 changes: 0 additions & 7 deletions services/ui-src/src/store/formData.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ export default (state = initialState, action) => {
updatedData[0].contents.section.subsections[0].parts[0].questions[0] =
lastYearData[0].contents.section.subsections[0].parts[0].questions[0]; // Name
}
if (
!updatedData[0].contents.section.subsections[0].parts[0].questions[1]
.answer.entry
) {
updatedData[0].contents.section.subsections[0].parts[0].questions[1] =
lastYearData[0].contents.section.subsections[0].parts[0].questions[1]; // Type
}
gmrabian marked this conversation as resolved.
Show resolved Hide resolved
// Cohort Questions - These should be revolving around a 2 year cycle, but today just pull forward
if (twoYearCycle) {
updatedData[3].contents.section.subsections[2].parts[5].questions[1].answer =
Expand Down
16 changes: 4 additions & 12 deletions services/ui-src/src/util/shouldDisplay.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { selectFragmentById } from "../store/formData";
import { AppRoles } from "../types";
import jsonpath from "./jsonpath";
import {
Expand Down Expand Up @@ -175,19 +176,10 @@ const hideIfTableValue = (state, hideIfTableValueInfo) => {
* @returns {boolean} - determines if an element should be filtered out, returning true means a question will display
*/
const shouldDisplay = (state, context, programType = null) => {
let program, reportStatusCode;
let program;
if (state.stateUser.currentUser.role === AppRoles.CMS_ADMIN) return true;
if (!programType) {
// If program type is not provided as an argument (the user is a bus_user, co_user), use the value for program type present in state
if (state.stateUser.currentUser.role === AppRoles.STATE_USER) {
reportStatusCode = state.stateUser.abbr + state.global.formYear;
} else {
reportStatusCode = state.formData[0].stateId + state.formData[0].year;
}
program = state.reportStatus[reportStatusCode].programType;
} else {
program = programType;
}
program =
programType ?? selectFragmentById(state, "2023-00-a-01-02").answer.entry;
gmrabian marked this conversation as resolved.
Show resolved Hide resolved

if (
!context ||
Expand Down
7 changes: 7 additions & 0 deletions services/ui-src/src/util/shouldDisplay.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { shouldDisplay } from "./shouldDisplay";
import { AppRoles } from "../types";

jest.mock("../store/formData", () => ({
...jest.requireActual("../store/formData"),
selectFragmentById: () => ({
answer: { entry: "test program" },
}),
}));

describe("shouldDisplay", () => {
it("should display everything for CMS Admins", () => {
const state = {
Expand Down
Loading