-
Notifications
You must be signed in to change notification settings - Fork 71
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) obsGroup count validation #150
(feat) obsGroup count validation #150
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Jamie, Nice work. Left some minor review comments
src/utils/ohri-form-helper.ts
Outdated
import { fetchConceptNameByUuid } from '../api/api'; | ||
import { ConceptTrue } from '../constants'; | ||
import { EncounterContext } from '../ohri-form-context'; | ||
import { OHRIFormField, OHRIFormPage, OHRIFormSection, SubmissionHandler } from '../api/types'; | ||
import { OHRIFormField, OHRIFormPage, OHRIFormSection, OpenmrsEncounter, SubmissionHandler } from '../api/types'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You added showToast
and OpenmrsEncounter
imports but looks like you don't use them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is resolved.
|
||
//validate obs group count against limit | ||
const limit = field.questionOptions.repeatOptions?.limit; | ||
const counter = obsGroupCounter?.filter((eachItem) => eachItem.fieldId === field.id)[0]?.obsGroupCount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a possible point of failure. What is this line meant to achieve? is there a hidden field with the count?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Count always defaults to 1 as is implemented in the repeating component, and I pass this to the obsGroupCounter state, and with any cloned obsGroup added the count is updated and passed to the obsGroupCounter at the beginning of the array. Not sure if this answers your question.
src/api/types.ts
Outdated
@@ -311,3 +311,9 @@ export interface ReferencedForm { | |||
formName: string; | |||
alias: string; | |||
} | |||
|
|||
export type TobsGroupCounter = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This naming doesn't look intuitive enough especially with the T
can rename it to RepeatGroupCounter
or ObsGroupCounter
or something else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is resolved.
showToast({ | ||
description: 'obsGroup count does not match limit specified', | ||
title: 'Invalid entry', | ||
kind: 'error', | ||
critical: true, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should move away from using Toasts to represent form validation errors and follow the conventions defined in the O3 style guide. We should instead use "Inline" notifications for validation errors.
PS: We should also do a refactor in other places like "after successfully submitting the form" to render a "Snackbar" as opposed to the "Toast".
See: https://zeroheight.com/23a080e38/p/683580-notifications
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is noted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samuelmale Work on this has been slated to be fixed under technical debt together with a refactor for all other applicable areas concerning this, and as such will not be resolved in this PR.
cc: @eudson
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct @arodidev ... we agree that the standards need to be followed but lets not block this specific PR.
Requirements
Summary
This PR validates that the number of repeated obsGroup fields matches the repeat limit passed into the form's JSON
Screenshots
Related Issue
Other