Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmale committed Aug 6, 2024
1 parent 06300f4 commit 567aa8a
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 448 deletions.
21 changes: 1 addition & 20 deletions src/components/group/obs-group.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,11 @@ export const ObsGroup: React.FC<FormFieldInputProps> = ({ field }) => {
?.filter((child) => !child.isHidden)
.map((child, index) => {
const keyId = child.id + '_' + index;
const rendering = child.questionOptions.rendering;
if (formFieldAdapters[child.type]) {
return (
<div className={classNames(styles.flexColumn)} key={keyId}>
<div className={styles.groupContainer}>
<div
className={classNames({
[styles.questionInfoDefault]: child.questionInfo && rendering === 'radio',
[styles.questionInfoCentralized]: child.questionInfo && rendering !== 'radio',
})}>
<div
className={classNames({
[styles.flexFullWidth]: [
'ui-select-extended',
'content-switcher',
'select',
'textarea',
'text',
'checkbox',
].includes(rendering),
})}>
<FormFieldRenderer field={child} valueAdapter={formFieldAdapters[child.type]} />
</div>
</div>
<FormFieldRenderer field={child} valueAdapter={formFieldAdapters[child.type]} />
</div>
</div>
);
Expand Down
3 changes: 1 addition & 2 deletions src/components/group/obs-group.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
}

.groupContainer {
margin-top: 0.5rem;
margin-bottom: 1.5rem;
margin: 0.5rem 0;
}
2 changes: 1 addition & 1 deletion src/components/inputs/radio/radio.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const Radio: React.FC<FormFieldInputProps> = ({ field, value, errors, warnings,
value={answer.concept}
key={index}
onClick={(e) => {
if (field.value && e.target.checked) {
if (value && e.target.checked) {
e.target.checked = false;
handleChange(null);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/components/renderer/form/form-renderer.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export const FormRenderer = ({ processorContext, initialValues, setIsLoadingForm
<FormProvider {...context}>
{formJson.pages.map((page) => {
const pageHasNoVisibleContent =
page.sections.every((section) => section.isHidden) ||
page.sections.every((section) => section.questions.every((question) => question.isHidden)) ||
page.sections?.every((section) => section.isHidden) ||
page.sections?.every((section) => section.questions?.every((question) => question.isHidden)) ||
isTrue(page.isHidden);
if (!page.isSubform && pageHasNoVisibleContent) {
return null;
Expand Down
28 changes: 1 addition & 27 deletions src/components/renderer/section/section-renderer.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,16 @@ import { FormFieldRenderer } from '../field/form-field-renderer.component';
import styles from './section-renderer.scss';
import classNames from 'classnames';
import { hasRendering } from '../../../utils/common-utils';
import Tooltip from '../../inputs/tooltip/tooltip.component';

export const SectionRenderer = ({ section }: { section: FormSection }) => {
const { t } = useTranslation();
const { formFieldAdapters } = useFormProviderContext();
const sectionId = useMemo(() => section.label.replace(/\s/g, ''), [section.label]);
return (
<div className={styles.section}>
{section.questions.map((question) =>
formFieldAdapters[question.type] ? (
<div key={`${sectionId}-${question.id}`} className={styles.sectionBody}>
<div
className={classNames({
[styles.questionInfoDefault]: question.questionInfo && hasRendering(question, 'radio'),
[styles.questionInfoCentralized]: question.questionInfo && !hasRendering(question, 'radio'),
})}>
<div
className={classNames({
[styles.flexFullWidth]: [
'ui-select-extended',
'content-switcher',
'select',
'textarea',
'text',
'checkbox',
].includes(question.questionOptions.rendering),
})}>
<FormFieldRenderer key={question.id} field={question} valueAdapter={formFieldAdapters[question.type]} />
</div>
{/** TODO: move tooltip to the form-field renderer; see: https://github.com/openmrs/openmrs-form-engine-lib/pull/351 */}
{!question.isHidden && question.questionInfo && (
<div className={styles.questionInfoContainer}>
<Tooltip field={question} />
</div>
)}
</div>
<FormFieldRenderer key={question.id} field={question} valueAdapter={formFieldAdapters[question.type]} />
</div>
) : null,
)}
Expand Down
13 changes: 0 additions & 13 deletions src/components/renderer/section/section-renderer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,6 @@
flex-basis: 100%;
}

.questionInfoContainer {
margin: 0 0.25rem;
}

.questionInfoDefault {
display: flex;
}

.questionInfoCentralized {
display: flex;
align-items: center !important;

> .questionInfoContainer {
padding-top: 1.5rem;
}
}
2 changes: 1 addition & 1 deletion src/components/repeat/repeat.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const Repeat: React.FC<FormFieldInputProps> = ({ field }) => {
<hr className={styles.divider} />
</div>
)}
{isGrouped ? <div className={styles.obsGroupContainer}>{component}</div> : component}
<div className={styles.nodeContainer}>{component}</div>
{!isViewMode(sessionMode) && (
<RepeatControls
question={field}
Expand Down
2 changes: 1 addition & 1 deletion src/components/repeat/repeat.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
margin-left: 0.5rem;
}

.obsGroupContainer {
.nodeContainer {
margin: 1rem 0rem;
}

Expand Down
Loading

0 comments on commit 567aa8a

Please sign in to comment.