Skip to content

Commit

Permalink
(fix) O3-3970 Re-enable readonly fields
Browse files Browse the repository at this point in the history
  • Loading branch information
pirupius committed Sep 26, 2024
1 parent d1a9a16 commit 03a8484
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/components/inputs/date/date.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const DateField: React.FC<FormFieldInputProps> = ({ field, value: dateValue, err
disabled={field.datePickerFormat === 'timer' ? field.isDisabled : !dateValue ? true : false}
invalid={errors.length > 0}
invalidText={errors[0]?.message}
readOnly={isTrue(field.readonly)}
warning={warnings.length > 0}
warningText={warnings[0]?.message}
value={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const MultiSelect: React.FC<FormFieldInputProps> = ({ field, value, errors, warn
readOnly={field.readonly}
/>
) : (
<CheckboxGroup legendText={label} name={field.id}>
<CheckboxGroup legendText={label} name={field.id} readOnly={isTrue(field.readonly)}>
{field.questionOptions.answers?.map((value, index) => {
return (
<Checkbox
Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/number/number.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const NumberField: React.FC<FormFieldInputProps> = ({ field, value, errors, warn
hideSteppers={true}
onWheel={(e) => e.target.blur()}
disabled={field.isDisabled}
readOnly={field.readonly}
readOnly={isTrue(field.readonly)}
className={classNames(styles.controlWidthConstrained, styles.boldedLabel)}
warn={warnings.length > 0}
warnText={warnings[0]?.message}
Expand Down
1 change: 1 addition & 0 deletions src/components/inputs/radio/radio.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const Radio: React.FC<FormFieldInputProps> = ({ field, value, errors, warnings,
name={field.id}
valueSelected={value}
onChange={handleChange}
readOnly={isTrue(field.readonly)}
orientation={field.questionOptions?.orientation || 'vertical'}>
{field.questionOptions.answers
.filter((answer) => !answer.isHidden)
Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/select/dropdown.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const Dropdown: React.FC<FormFieldInputProps> = ({ field, value, errors, warning
selectedItem={isEmpty(value) ? NullSelectOption : value}
onChange={handleChange}
disabled={field.isDisabled}
readOnly={field.readonly}
readOnly={isTrue(field.readonly)}
invalid={errors.length > 0}
invalidText={errors[0]?.message}
warn={warnings.length > 0}
Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/text-area/text-area.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const TextArea: React.FC<FormFieldInputProps> = ({ field, value, errors, warning
value={value || ''}
rows={field.questionOptions.rows || 4}
disabled={field.isDisabled}
readOnly={field.readonly}
readOnly={isTrue(field.readonly)}
invalid={errors.length > 0}
invalidText={errors[0]?.message}
warn={warnings.length > 0}
Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/toggle/toggle.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const Toggle: React.FC<FormFieldInputProps> = ({ field, value, errors, warnings,
onToggle={handleChange}
toggled={!!value}
disabled={field.isDisabled}
readOnly={field.readonly}
readOnly={isTrue(field.readonly)}
/>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const UiSelectExtended: React.FC<FormFieldInputProps> = ({ field, errors, warnin
setFieldValue(selectedItem?.uuid);
}}
disabled={field.isDisabled}
readOnly={field.readonly}
readOnly={isTrue(field.readonly)}
invalid={errors.length > 0}
invalidText={errors.length && errors[0].message}
onInputChange={(value) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next';
import { showSnackbar } from '@openmrs/esm-framework';
import { useLaunchWorkspaceRequiringVisit } from '@openmrs/esm-patient-common-lib';
import { Button } from '@carbon/react';
import { isTrue } from 'src/utils/boolean-utils';
import { type FormFieldInputProps } from '../../../types';
import styles from './workspace-launcher.scss';

Expand All @@ -27,7 +28,7 @@ const WorkspaceLauncher: React.FC<FormFieldInputProps> = ({ field }) => {
<div>
<div className={styles.label}>{t(field.label)}</div>
<div className={styles.workspaceButton}>
<Button onClick={handleLaunchWorkspace}>{field.questionOptions?.buttonLabel ?? t('launchWorkspace')}</Button>
<Button disabled={isTrue(field.readonly)} onClick={handleLaunchWorkspace}>{field.questionOptions?.buttonLabel ?? t('launchWorkspace')}</Button>
</div>
</div>
)
Expand Down

0 comments on commit 03a8484

Please sign in to comment.