Skip to content

Commit

Permalink
avniproject/avni-product#1453 | Ability to configure Subject Type set…
Browse files Browse the repository at this point in the history
…tings
  • Loading branch information
1t5j0y committed Mar 11, 2024
1 parent 0cadd9b commit d5a342b
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 3 deletions.
4 changes: 3 additions & 1 deletion public/documentation/toolTip.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"APP_DESIGNER_NAME_HELP_TEXT": "Help text will be displayed on the first name field.",
"APP_DESIGNER_SUBJECT_TYPE_GROUP_ROLES": "Member roles that you can choose from while adding members to this group",
"APP_DESIGNER_SUBJECT_TYPE_SYC_BY_LOCATION": "This will sync the subjects by their registered locations and catchment assigned to the users",
"APP_DESIGNER_SUBJECT_TYPE_SYNC_BY_DIRECT_ASSIGNMENT": "This will sync the subjects which are sirectly assigned to the users",
"APP_DESIGNER_SUBJECT_TYPE_SYNC_BY_DIRECT_ASSIGNMENT": "This will sync the subjects which are directly assigned to the users",
"APP_DESIGNER_SUBJECT_TYPE_DISPLAY_REGISTRATION_DETAILS": "Controls if registration details are shown to the field user on subject profile screen",
"APP_DESIGNER_SUBJECT_TYPE_DISPLAY_PLANNED_ENCOUNTERS": "Controls if planned visits are shown to the field user on the subject dashboard screens",
"APP_DESIGNER_SUBJECT_MEMBER_SUBJECT_TYPE": "Person subject type that can be added as member to the household",
"APP_DESIGNER_PROFILE_PICTURE_ICON": "Profile picture of an individual",
"APP_DESIGNER_PROGRAM_NAME": "Name of the program.",
Expand Down
6 changes: 5 additions & 1 deletion src/adminApp/Constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ export const subjectTypeInitialState = {
subjectSummaryRule: "",
programEligibilityCheckRule: "",
shouldSyncByLocation: true,
lastNameOptional: false
lastNameOptional: false,
settings: {
displayRegistrationDetails: true,
displayPlannedEncounters: true
}
};
5 changes: 5 additions & 0 deletions src/adminApp/Reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ export function subjectTypeReducer(subjectType, action) {
...subjectType,
nameHelpText: action.payload
};
case "settings":
return {
...subjectType,
settings: { ...subjectType.settings, [action.payload.setting]: action.payload.value }
};
default:
return subjectType;
}
Expand Down
12 changes: 12 additions & 0 deletions src/adminApp/SubjectType/AdvancedSettingShow.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ export const AdvancedSettingShow = ({ locationTypes, subjectType }) => {
status={subjectType.directlyAssignable}
label={"Sync By Direct Assignment"}
/>
{!isEmpty(subjectType.settings) && (
<div>
<BooleanStatusInShow
status={subjectType.settings.displayRegistrationDetails}
label={"Display Registration Details"}
/>
<BooleanStatusInShow
status={subjectType.settings.displayPlannedEncounters}
label={"Display Planned Encounters"}
/>
</div>
)}
<ConceptSyncAttributesShow
subjectType={subjectType}
concept1Name={concept1Name}
Expand Down
28 changes: 27 additions & 1 deletion src/adminApp/SubjectType/AdvancedSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ValidFormat } from "./ValidFormat";
import { CustomisedAccordionSummary } from "../components/CustomisedExpansionPanelSummary";
import { findFormUuidForSubjectType } from "../domain/formMapping";
import http from "../../common/utils/httpClient";
import { forEach, get, includes } from "lodash";
import { forEach, get, includes, isEmpty } from "lodash";
import { OptionSelect } from "./OptionSelect";
import { Accordion, AccordionDetails, Box, Input } from "@material-ui/core";
import { AvniFormLabel } from "../../common/components/AvniFormLabel";
Expand Down Expand Up @@ -198,6 +198,32 @@ export const AdvancedSettings = ({
value={get(subjectType, `nameHelpText`, "")}
onChange={event => dispatch({ type: "nameHelpText", payload: event.target.value })}
/>
{!isEmpty(subjectType.settings) && (
<div>
<AvniSwitch
checked={!!subjectType.settings.displayRegistrationDetails}
onChange={event =>
dispatch({
type: "settings",
payload: { setting: "displayRegistrationDetails", value: event.target.checked }
})
}
name="Display Registration Details"
toolTipKey={"APP_DESIGNER_SUBJECT_TYPE_DISPLAY_REGISTRATION_DETAILS"}
/>
<AvniSwitch
checked={!!subjectType.settings.displayPlannedEncounters}
onChange={event =>
dispatch({
type: "settings",
payload: { setting: "displayPlannedEncounters", value: event.target.checked }
})
}
name="Display Planned Encounters"
toolTipKey={"APP_DESIGNER_SUBJECT_TYPE_DISPLAY_PLANNED_ENCOUNTERS"}
/>
</div>
)}
<Box component={"div"} mt={3} mb={2} p={2} border={1} borderColor={"#e1e1e1"}>
<Typography gutterBottom variant={"subtitle1"}>
{"Sync Settings"}
Expand Down

0 comments on commit d5a342b

Please sign in to comment.