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

(feat) O3-2972: Validate number fields whose concepts don't allow decimal values #251

Merged
merged 2 commits into from
Apr 19, 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
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ const AddQuestionModal: React.FC<AddQuestionModalProps> = ({
})),
}),
...(questionType === 'personAttribute' && { attributeType: selectedPersonAttributeType.uuid }),
...(questionType === 'obs' &&
renderingType === 'number' &&
selectedConcept?.allowDecimal === false && { disallowDecimals: true }),
},
validators: [],
};
Expand Down Expand Up @@ -482,6 +485,14 @@ const AddQuestionModal: React.FC<AddQuestionModalProps> = ({
</div>
)}

{selectedConcept?.allowDecimal === false && (
<InlineNotification
kind="info"
lowContrast
title={t('decimalsNotAllowed', 'This concept does not allow decimals')}
/>
)}

{conceptMappings?.length ? (
<FormGroup>
<FormLabel className={styles.label}>{t('mappings', 'Mappings')}</FormLabel>
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export interface Concept {
display: string;
mappings: Array<Mapping>;
answers: Array<ConceptAnswer>;
allowDecimal?: boolean;
}

export interface ConceptAnswer {
Expand Down
1 change: 1 addition & 0 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"createNewQuestion": "Create a new question",
"createNewSection": "Create a new section",
"datePickerType": "The type of date picker to show ",
"decimalsNotAllowed": "This concept does not allow decimals",
"delete": "Delete",
"deleteForm": "Delete form",
"deleteFormConfirmation": "Are you sure you want to delete this form?",
Expand Down
Loading