diff --git a/src/adminApp/SubjectType/AdvancedSettings.js b/src/adminApp/SubjectType/AdvancedSettings.js index fae8c0828..e580c70ee 100644 --- a/src/adminApp/SubjectType/AdvancedSettings.js +++ b/src/adminApp/SubjectType/AdvancedSettings.js @@ -11,6 +11,7 @@ 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"; +import { SubjectTypeType } from "./Types"; const CustomAccordion = withStyles({ root: { @@ -34,18 +35,11 @@ const CustomAccordianDetails = withStyles(theme => ({ CustomAccordianDetails.muiName = "AccordionDetails"; const syncAttributeDataTypes = ["Numeric", "Coded", "Text"]; -export const AdvancedSettings = ({ - subjectType, - dispatch, - locationTypes, - formMappings, - isEdit -}) => { +export const AdvancedSettings = ({ subjectType, dispatch, locationTypes, formMappings, isEdit }) => { const [expanded, setExpanded] = React.useState(false); const [syncAttributes, setSyncAttributes] = React.useState([]); const formUuid = findFormUuidForSubjectType(subjectType, formMappings); - const changeSyncAttribute = (name, value) => - dispatch({ type: "syncAttribute", payload: { name, value } }); + const changeSyncAttribute = (name, value) => dispatch({ type: "syncAttribute", payload: { name, value } }); const onSyncConceptChange = (name, value) => { const syncAttributeChangeMessage = @@ -65,12 +59,7 @@ export const AdvancedSettings = ({ forEach(form.formElementGroups, feg => { forEach(feg.formElements, fe => { const concept = fe.concept; - if ( - !feg.voided && - !fe.voided && - fe.mandatory && - includes(syncAttributeDataTypes, concept.dataType) - ) { + if (!feg.voided && !fe.voided && fe.mandatory && includes(syncAttributeDataTypes, concept.dataType)) { syncAttributes.push({ label: concept.name, value: concept.uuid }); } }); @@ -95,9 +84,7 @@ export const AdvancedSettings = ({ - dispatch({ type: "allowEmptyLocation", payload: event.target.checked }) - } + onChange={event => dispatch({ type: "allowEmptyLocation", payload: event.target.checked })} name="Allow Empty Location" toolTipKey={"APP_DESIGNER_SUBJECT_TYPE_ALLOW_EMPTY_LOCATION"} /> @@ -111,9 +98,7 @@ export const AdvancedSettings = ({ - dispatch({ type: "allowProfilePicture", payload: event.target.checked }) - } + onChange={event => dispatch({ type: "allowProfilePicture", payload: event.target.checked })} name="Allow Profile Picture" toolTipKey={"APP_DESIGNER_SUBJECT_TYPE_ALLOW_PROFILE_PICTURE"} /> @@ -124,11 +109,7 @@ export const AdvancedSettings = ({ regexLabel={subjectType.type === "Person" ? "First Name Regex" : "Name Regex"} regexToolTipKey={"APP_DESIGNER_FIRST_NAME_REGEX"} regexID={"validFirstNameRegex"} - descKeyLabel={ - subjectType.type === "Person" - ? "First Name Validation Description Key" - : "Name Validation Description Key" - } + descKeyLabel={subjectType.type === "Person" ? "First Name Validation Description Key" : "Name Validation Description Key"} descToolTipKey={"APP_DESIGNER_FIRST_NAME_DESCRIPTION_KEY"} descID={"validFirstNameDescriptionKey"} propertyName={"validFirstNameFormat"} @@ -228,32 +209,38 @@ export const AdvancedSettings = ({ {"Sync Settings"} - changeSyncAttribute("shouldSyncByLocation", event.target.checked)} - name="Sync by location" - toolTipKey={"APP_DESIGNER_SUBJECT_TYPE_SYC_BY_LOCATION"} - /> - changeSyncAttribute("directlyAssignable", event.target.checked)} - name="Sync by direct assignment" - toolTipKey={"APP_DESIGNER_SUBJECT_TYPE_SYNC_BY_DIRECT_ASSIGNMENT"} - /> - onSyncConceptChange("syncRegistrationConcept1", value)} - /> - onSyncConceptChange("syncRegistrationConcept2", value)} - /> + {subjectType.type === SubjectTypeType.User ? ( + Determined by Subject Type + ) : ( + <> + changeSyncAttribute("shouldSyncByLocation", event.target.checked)} + name="Sync by location" + toolTipKey={"APP_DESIGNER_SUBJECT_TYPE_SYC_BY_LOCATION"} + /> + changeSyncAttribute("directlyAssignable", event.target.checked)} + name="Sync by direct assignment" + toolTipKey={"APP_DESIGNER_SUBJECT_TYPE_SYNC_BY_DIRECT_ASSIGNMENT"} + /> + onSyncConceptChange("syncRegistrationConcept1", value)} + /> + onSyncConceptChange("syncRegistrationConcept2", value)} + /> + + )} diff --git a/src/adminApp/SubjectType/SubjectTypeEdit.js b/src/adminApp/SubjectType/SubjectTypeEdit.js index 08578d32c..1f3e547de 100644 --- a/src/adminApp/SubjectType/SubjectTypeEdit.js +++ b/src/adminApp/SubjectType/SubjectTypeEdit.js @@ -22,6 +22,7 @@ import { MessageReducer } from "../../formDesigner/components/MessageRule/Messag import { getMessageRules, getMessageTemplates, saveMessageRules } from "../service/MessageService"; import MessageRules from "../../formDesigner/components/MessageRule/MessageRules"; import { connect } from "react-redux"; +import { SubjectTypeType } from "./Types"; const SubjectTypeEdit = ({ organisationConfig, ...props }) => { const [subjectType, dispatch] = useReducer(subjectTypeReducer, subjectTypeInitialState); @@ -87,11 +88,7 @@ const SubjectTypeEdit = ({ organisationConfig, ...props }) => { setNameValidation(false); if (!groupValidationError) { - const [s3FileKey, error] = await uploadImage( - subjectType.iconFileS3Key, - file, - bucketName.ICONS - ); + const [s3FileKey, error] = await uploadImage(subjectType.iconFileS3Key, file, bucketName.ICONS); if (error) { alert(error); return; @@ -140,12 +137,7 @@ const SubjectTypeEdit = ({ organisationConfig, ...props }) => { } }; - if ( - !_.isEmpty(formMappings) && - !_.isEmpty(subjectType.uuid) && - !firstTimeFormValueToggle && - _.isEmpty(subjectType.registrationForm) - ) { + if (!_.isEmpty(formMappings) && !_.isEmpty(subjectType.uuid) && !firstTimeFormValueToggle && _.isEmpty(subjectType.registrationForm)) { setFirstTimeFormValueToggle(true); let payload = findRegistrationForm(formMappings, subjectType); dispatch({ type: "registrationForm", payload: payload }); @@ -153,8 +145,7 @@ const SubjectTypeEdit = ({ organisationConfig, ...props }) => { const disableDelete = _.find( subjectTypes, - ({ group, memberSubjectUUIDs }) => - group && _.includes(memberSubjectUUIDs.split(","), subjectType.uuid) + ({ group, memberSubjectUUIDs }) => group && _.includes(memberSubjectUUIDs.split(","), subjectType.uuid) ); return ( @@ -167,14 +158,22 @@ const SubjectTypeEdit = ({ organisationConfig, ...props }) => {
- + {subjectType.type === SubjectTypeType.User ? ( +
+ Type +
+ {subjectType.type} +
+ ) : ( + + )} {organisationConfig && organisationConfig.enableMessaging ? (