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

Form Engine UI refactor #168

Merged
merged 31 commits into from
Mar 7, 2024
Merged

Conversation

arodidev
Copy link
Contributor

@arodidev arodidev commented Feb 6, 2024

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

Summary

This PR aims to tackle various issues:

  • Responsiveness of the controls rendered on the form.
  • Refactoring of previous value out of the control component and made to render independently
  • Fixing previous value for various fields, missing or non-functional
  • Refactor controls to pull cross-cutting styles from a single stylesheet
  • Remove previous value functionality from obsGroup fields.
  • Refactoring questionInfo tooltip positions for controls
  • Add functionality to dynamically set control width from the form JSON
  • Fixing control misalignment within the obsGroups

Screenshots

Screen.Recording.2024-02-06.at.08.44.46.mov

Related Issue

Other

@arodidev arodidev marked this pull request as ready for review February 7, 2024 10:10
Copy link
Member

@pirupius pirupius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work with the clean up and refactors. I have some concerns about the naming and duplication of variable names

src/components/inputs/number/ohri-number.component.tsx Outdated Show resolved Hide resolved
src/components/inputs/text/ohri-text.component.tsx Outdated Show resolved Hide resolved
src/components/inputs/unspecified/ohri-unspecified.scss Outdated Show resolved Hide resolved
src/components/section/ohri-form-section.component.tsx Outdated Show resolved Hide resolved
src/components/section/ohri-form-section.component.tsx Outdated Show resolved Hide resolved
src/components/section/ohri-form-section.component.tsx Outdated Show resolved Hide resolved
src/components/section/ohri-form-section.scss Outdated Show resolved Hide resolved
src/ohri-form.component.scss Outdated Show resolved Hide resolved
Copy link
Member

@samuelmale samuelmale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @arodidev, just a few comments. Maybe as a general comment: There is no linked ticket to define the scope of work which makes the review process tricky. Plus I'm in agreement with harmonizing the cross-cutting stylings but styles specific to input components shouldn't be migrated to the ohri-form-section.sccs file.

src/api/types.ts Outdated Show resolved Hide resolved
src/api/types.ts Outdated Show resolved Hide resolved
src/components/group/ohri-obs-group.scss Show resolved Hide resolved
src/components/section/ohri-form-section.component.tsx Outdated Show resolved Hide resolved
src/components/section/ohri-form-section.component.tsx Outdated Show resolved Hide resolved
src/components/section/ohri-form-section.scss Outdated Show resolved Hide resolved
src/components/section/ohri-form-section.scss Outdated Show resolved Hide resolved
src/submission-handlers/base-handlers.ts Outdated Show resolved Hide resolved
src/utils/common-expression-helpers.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@eudson eudson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets merge this and have the enhancements ticketed for a different PR.

@CynthiaKamau
Copy link
Contributor

Thanks @arodidev , kindly fix the conflicts

@arodidev
Copy link
Contributor Author

arodidev commented Mar 6, 2024

Thanks @arodidev , kindly fix the conflicts

Thanks, resolved.

@samuelmale samuelmale dismissed their stale review March 6, 2024 08:38

The unresolved requested changes are blocking the merge button.

Copy link
Member

@pirupius pirupius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some final touch up comments

}
export interface previousValue {
field: string;
value: string | number | Date | boolean | previousValue[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which usecase is previousValue[] for? multichoice? Not really comfortable with it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The multi-select input component receives its values as an array of type previousValue

@@ -20,6 +21,15 @@ export const OHRIContentSwitcher: React.FC<OHRIFormFieldProps> = ({ question, on
}
}, [question]);

useEffect(() => {
if (!isEmpty(previousValue)) {
const { value } = previousValue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a little bit of inconsistency on how the previous value is being accessed. In different controls.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to the differences in datatypes of the previousValues for specific controls, otherwise I think the format is pretty standard across the board, maybe expound a bit?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a show stopper. There other controls that access it with previousValue.value and others do is this way based on your PR

@@ -144,15 +154,13 @@ const OHRIDate: React.FC<OHRIFormFieldProps> = ({ question, onChange, handler })
) : (
!question.isHidden && (
<>
<div className={`${styles.formField} ${styles.row} ${styles.datetime}`}>
<div className={`${styles.datetime}`}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit picking but we don't need the extra literal since the other styles have been stripped

@@ -114,9 +119,9 @@ export const OHRIMultiSelect: React.FC<OHRIFormFieldProps> = ({ question, onChan
readOnly={question.readonly}
/>
</div>
<div className={styles.formField} style={{ marginTop: '0.125rem' }}>
<div style={{ marginTop: '0.125rem' }}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a style that is used in other controls? Let's extract this to the scss file

display: flex;
flex-direction: row;
align-items: center;
.errorLegend legend {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation on this file looks off. Please format this to 2 spaces

display: flex;
flex-direction: row;
align-items: baseline;
.boldedLabel label {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same applies to this file around indenting

@@ -69,6 +69,16 @@ const UISelectExtended: React.FC<OHRIFormFieldProps> = ({ question, handler, onC
question.value = handler?.handleFieldSubmission(question, value, encounterContext);
};

useEffect(() => {
if (!isEmpty(previousValue)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a control we want to add a previous value to? So much is happening already with the search and might have some points of failure or conflict

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, although previousValue was already supported by ui-select-extended prior to this PR.

@arodidev arodidev merged commit 8c5cf5b into openmrs:main Mar 7, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants